jade 模板标签括号百分比定义 [英] jade template tag bracket percentage definition

查看:60
本文介绍了jade 模板标签括号百分比定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在石膏板注册页面中阅读了以下玉石代码,但不确定 <% <%= 的外观是什么意思?有谁能告诉我吗?

I was reading the following jade code in drywall signup page and not sure about what the appearances of <% <%= means ? Can any one tell me ?

  script(type='text/template', id='tmpl-signup')
form
  div.alerts
    |<% _.each(errors, function(err) { %>
    div.alert.alert-danger.alert-dismissable
      button.close(type='button', data-dismiss='alert') &times;
      |<%= err %>
    |<% }); %>
  div.form-group(class!='<%= errfor.username ? "has-error" : "" %>')
    label.control-label Pick a Username:
    input.form-control(type='text', name='username', value!='<%= username %>')
    span.help-block <%= errfor.username %>
  div.form-group(class!='<%= errfor.email ? "has-error" : "" %>')
    label.control-label Enter Your Email:
    input.form-control(type='text', name='email', value!='<%= email %>')
    span.help-block <%= errfor.email %>
  div.form-group(class!='<%= errfor.password ? "has-error" : "" %>')
    label.control-label Create a Password:
    input.form-control(type='password', name='password', value!='<%= password %>')
    span.help-block <%= errfor.password %>
  div.form-group
    button.btn.btn-primary.btn-signup(type='button') Create My Account

推荐答案

<% 和 %> 表示将被解释为 javascript 的代码块,并将在呈现模板之前执行.例如,下面的块

<% and %> denote a block of code which will be interpreted as javascript, and will be executed before the template is rendered. For instance, the following block

input.form-control(type='text', name='email', value!='<%= email %>')

将变量 'email' 插入到呈现的 html 中,以便文本框的值等于该变量.类似地,forEach 循环和 IF 语句在插入 <% %> 块

Will insert the variable 'email' into the rendered html, so that the value of the textbox will equal to that variable. Similarly, forEach loops, and IF statements function just as they would in plain JavaScript when inserted into a <% %> block

这篇关于jade 模板标签括号百分比定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆