安装

npm install ect

语法

非转义输出

<%- variable %>

转义输出

<%= variable %>

For 循环

<% for article in @articles: %>
    // do something
<% end %>

If 条件

<% if @user.authenticated: %>
    // do something
<% else: %>
    // do something else
<% end %>

Switch 语句

<% switch @user.oauthProvider: %>
    <% when 'facebook': %>
        // something
    <% end %>
    <% when 'twitter': %>
        // something
    <% end %>
    <% else : %>
        // something
    <% end %>
<% end %>

继承

<% extend 'parentTemplate' %>

在父模板中使用 <% content %> 语句定义插入点。

包含

<% include 'partial' %>

向包含的模板传递上下文:

<% include 'partial', {name: 'Hello, world!'} %>

<% block 'blockName': %>
    // the content of block
<% end %>

在父模板中使用 <% content 'blockName' %> 语句定义块插入点。




Comments

comments powered by Disqus