- Page: README, Leaf, Stencil, swift-html, Swift Language (organic), Template Syntax
- Section: Approach • Cases • Getting Started • Observations • Preliminary Setup • Resources
The eval-vapor-leaf-stencil Vapor project provides some select HTML templating examples with Leaf, Stencil, swift-html DSL (Domain Specific Language), and Swift Programming Language (organic).
Approach ▴
All approaches are setup to use the SwiftNIO EventLoopFuture<ResponseEncodable> (typealias Future<ResponseEncodable>). Three approaches (leaf, stencil, swiftlang) render a View for the ResponseEncodable. The swift-html renders a Html.Node for the ResponseEncodable.
Leaf /leaf/…
Stencil /stencil/…
swift-html DSL /swift-html/…
This approach extends Html.Node to be ResponseEncodable. Thus, the theses templates are rendered into an Html.Node instead of as a View.
Swift Organic /swiftlang/…
"Swift Organic" uses the Swift Programming Language swiftlang without any additional templating packages. This approach assembles a Swift String which is rendered to a Vapor ResponseEncodable View.
Cases ▴
For each use case, replace /<approach> with one of /leaf, /stencil, /swift-html, or /swiftlang in the URL localhost:8080/<approach>/<usecase> URL. For example, the Leaf approach URL for the "Hello" use case would be localhost:8080/hello/Sunshine.
About /<approach>
The /<approach> routes provide some information About specific to each <approach>.
Hello /<approach>/hello/<somename>
Markdown Blog Entries
Example Blog Entries in Resources/HtmlParts/ were converted from Markdown to HTML with Pandoc.
##############
### PANDOC ###
##############
## http://pandoc.org/MANUAL.html#pandocs-markdown
OPTIONS="markdown_strict"
OPTIONS="$OPTIONS+pipe_tables"
OPTIONS="$OPTIONS+space_in_atx_header"
OPTIONS="$OPTIONS+blank_before_blockquote"
OPTIONS="$OPTIONS+backtick_code_blocks"
OPTIONS="$OPTIONS+tex_math_dollars"
pandoc \
--from=$OPTIONS \
--to=html5 \
--mathjax \
--output=math.html \
math.mdHTML LaTeX Math /<approach>/math
Programming Blog Snippet /<approach>/codeblog
Markdown To HTML Elements /<approach>/mdtohtml
- See how markdown elements render via the templates.
- Determine if/when the HTML generated from Markdown needs modification to work with the template syntax.
Getting Started ▴
Observations ▴
Preliminary Setup ▴
vapor new eval-vapor-leaf-stencil --web
cd eval-vapor-leaf-stencil
mkdir README_files
touch README_files/.git_keep # create file so folder is not empty for `git`
vapor update -y-
GitHub/NocturnalSolutions: StencilBugTest ⇗ … illustrates a simple way to invoke Stencil.