Last active
November 10, 2015 01:05
-
-
Save satosystems/e9cfcac1cfb7a31255cf to your computer and use it in GitHub Desktop.
node.js で使えるテンプレートエンジン ref: http://qiita.com/satosystems/items/cf7b748c0f95c95aa48b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if (user) { %> | |
<h2><%= user.name %></h2> | |
<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<% users.forEach(function(user){ %> | |
<%- include('user/show', {user: user}); %> | |
<% }); %> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var swig = require('swig'); | |
swig.renderFile('/path/to/template.html', { | |
pagename: 'awesome people', | |
authors: ['Paul', 'Jim', 'Jane'] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var swig = require('swig'); | |
swig.renderFile('/path/to/template.html', { | |
pagename: 'awesome people', | |
authors: ['Paul', 'Jim', 'Jane'] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Awesome People</h1> | |
<ul> | |
<li class="first">Paul</li> | |
<li>Jim</li> | |
<li>Jane</li> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Awesome People</h1> | |
<ul> | |
<li class="first">Paul</li> | |
<li>Jim</li> | |
<li>Jane</li> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="timeline"> | |
<!-- load more button --> | |
<button>{{message}}</button> | |
<!-- tweet object --> | |
{{#tweets}} | |
{{> tweet}} | |
{{/tweets}} | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>{{header}}</h1> | |
{{#bug}} | |
{{/bug}} | |
{{#items}} | |
{{#first}} | |
<li><strong>{{name}}</strong></li> | |
{{/first}} | |
{{#link}} | |
<li><a href="{{url}}">{{name}}</a></li> | |
{{/link}} | |
{{/items}} | |
{{#empty}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"header": "Colors", | |
"items": [ | |
{"name": "red", "first": true, "url": "#Red"}, | |
{"name": "green", "link": true, "url": "#Green"}, | |
{"name": "blue", "link": true, "url": "#Blue"} | |
], | |
"empty": true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Colors</h1> | |
<li><strong>red</strong></li> | |
<li><a href="#Green">green</a></li> | |
<li><a href="#Blue">blue</a></li> | |
<p>The list is empty.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Colors</h1> | |
<li><strong>red</strong></li> | |
<li><a href="#Green">green</a></li> | |
<li><a href="#Blue">blue</a></li> | |
<p>The list is empty.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="entry"> | |
<h1>{{title}}</h1> | |
<div class="body"> | |
{{body}} | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
title: "My New Post", | |
body: "This is my first post!" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="entry"> | |
<h1>My New Post</h1> | |
<div class="body"> | |
This is my first post! | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="entry"> | |
<h1>My New Post</h1> | |
<div class="body"> | |
This is my first post! | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>{{ pagename|title }}</h1> | |
<ul> | |
{% for author in authors %} | |
<li{% if loop.first %} class="first"{% endif %}> | |
{{ author }} | |
</li> | |
{% endfor %} | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment