Thulium engine for Express 4
Install
npm install -save thulium-express
Dependencies
Neon a DSL Class system for Javascript. Thulium
Usage
Setup Express to use thulium views and thulium engine
var express = ;var app = ; ... app;app; // views go in __dirname/views// layouts in __dirname/view/layoutsapp; ...
Create views/layouts/application.html. This will be the default layout.
Within the context of a layout, yield identifies a section where content from the view should be inserted. The simplest way to use this is to have a single yield, into which the entire contents of the view currently being rendered is inserted:
Thulium Application layout <%= yield %> The footer
Write a route:
app;
Write the view for the route
// views/home/index.html<% posts.forEach(function(post) { %> Post : <%= post %><% }) %>
Partials
Partial templates are another device for breaking the rendering process into more manageable chunks. With a partial, you can move the code for rendering a particular piece of a response to its own file.
To render a partial as part of a view, you use the renderPartial method within the view:
<%= renderPartial('shared/posts', {posts : [1,2,3]}) %>