Interpolation

jade为不同的需求提供了一些特殊的操作符。详见Github

= 将右边的值赋予左边,或者替换为右边变量的值。

//- 赋值,js格式即可。
- var title = "On Dogs: Man's Best Friend"; //- 替换,注意左边无空格右边需有空格。
h= title

#{val}将引用处替换为val变量的值。

- var author = "Tom";

//- 编译生成的html中为Tom,而不是#{author}
p Written with love by #{author}

在属性那一章的特殊属性中曾提到,类似<这样的特殊符号编译后将为&lt。同样在使用#{val}的时候,若val变量的值含有这些特殊符号的时候,编译也会变成&lt这样的形式。

为了避免出现如上形式,可以采用!{val}

jade:

- var riskyBusiness = "<em>Some of the girls are wearing my mother's clothing.</em>";

.quote
p Joel: !{riskyBusiness}

html:

<div class="quote">
<p>Joel: <em>Some of the girls are wearing my mother's clothing.</em></p>
</div>

如果需要在文本内容中插入标签的话,可以使用#[...]

jade:

p.
If you take a look at this page's source #[a(target="_blank", href="https://github.com/jadejs/jade/blob/master/docs/views/reference/interpolation.jade") on GitHub],
you'll see several places where the tag interpolation operator is
used, like so.

html:

<p>If you take a look at this page's source <a target="_blank" href="https://github.com/jadejs/jade/blob/master/docs/views/reference/interpolation.jade">on GitHub</a>,
you'll see several places where the tag interpolation operator is
used, like so.
</p>

循环

jade支持for / while / each三种循环方式,其中for / while均与常见的循环一样。

each循环可以用来遍历整个数组。

jade:

- var name = ['Tom', 'Jim', 'Alex', 'Jack'];
each i in name
p= i

html:

<p>Tom</p>
<p>Jim</p>
<p>Alex</p>
<p>Jack</p>

Jade之Interpolation的更多相关文章

  1. pug模板引擎(原jade)

    前面的话 为什么要引入pug,pug有什么特别之处呢?有一些嵌套层次较深的页面,可能会出现巢状嵌套,如下图所示 在后期维护和修改时,一不小心少了一个尖括号,或者某个标签的开始和闭合没有对应上,就会导致 ...

  2. Jade模板引擎让你飞

    写在前面:现在jade改名成pug了 一.安装 npm install jade 二.基本使用 1.简单使用 p hello jade! 渲染后: <p>hello jade!</p ...

  3. emmet,jade,haml, slim,less,sass,coffeescript等的实战优缺点

    摘要: 文章背景,来自于群内周五晚上的一次头脑风暴式的思维碰撞交流活动. 随着前端技术的蓬勃发展, 各种新技术随着生产力的需要不断的涌入我们的视野, 那今天探讨的话题是这些新时代的前端兵器谱: 一. ...

  4. Vue ES6 Jade Scss Webpack Gulp

    一直以来非常庆幸曾经有翻过<代码大全2>:这使我崎岖编程之路少了很多不必要的坎坷.它在软件工艺的话题中有写到一篇:"首先是为人写程序,其次才是机器(Write Programs ...

  5. Jade 模板引擎使用

    在 Express 中调用 jade 模板引擎 jade 变量调用 if 判断 循环 Case 选择 在模板中调用其他语言 可重用的 jade 块 (Mixins) 模板包含 (Includes) 模 ...

  6. jade模板引擎

    最近用jade写了点东西,觉得挺有趣的,是一个有意思的模板引擎. 比如说,像这样的结构的html <span> <i class="icon-edit">& ...

  7. OPEN CASCADE BSpline Curve Interpolation

    OPEN CASCADE BSpline Curve Interpolation eryar@163.com Abstract. Global curve interpolation to point ...

  8. OpenCASCADE Interpolation - Lagrange

    OpenCASCADE Interpolation - Lagrange eryar@163.com Abstract. Power basis polynomial is the most simp ...

  9. 在webstorm设置File watcher for Jade

    用Jade模板引擎写html确实方便,元素不用闭合,很多种简写的方法. 为了要知道自己写的对不对,就要用到jade -w命令监控jade文件,只要变化就编译. 现在用webstorm写代码的超多,可以 ...

随机推荐

  1. Sybase alter 用法

    原文地址:http://lujinan858.iteye.com/blog/437019 --示例 1 为表添加列.Adaptive Server 为表中每个现有行分配一个 NULL --列值: al ...

  2. Chap5: question: 29 - 31

    29. 数组中出现次数超过一半的数字. 方法a. 排序取中       O(nlogn). 方法b. partition 函数分割找中位数     >=O(n). 方法c. 设计数变量,扫描一遍 ...

  3. 69. Letter Combinations of a Phone Number

    Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...

  4. 使用eclipse搭建hadoop开发环境

    下载一个 hadoop-eclipse-plugin-*.jar的eclipse插件,并放在plugins目录下 重启eclipse   打开视象,找“大象” 连接HDFS   success 编程准 ...

  5. [PAT]求集合数据的均方差(15)

    #include "stdio.h" #include "malloc.h" #include "math.h" int *getinput ...

  6. click事件

    click事件是可以多次绑定的,如果绑定多次就会执行多次,因此再不需要重复执行的情况下,就需要使用unbind对事件进行解绑

  7. Embed dll Files Within an exe (C# WinForms)—Winform 集成零散dll进exe的方法

    A while back I was working on a small C# WinForms application in Visual Studio 2008. For the sake of ...

  8. hive查询

    查询语句可以直接使用非分析函数的变量的别名 select t1.* from ( select account_id, sum(recharge_money) recharge_money_total ...

  9. Linux学习笔记——使用指定的用户权限执行程序——sudo

          sudo可以用来以其他用户身份执行命令,sudo命令可以针对单个命令授予临时权限.sudo仅在需要时授予用户权限,减少了用户因为错误执行命令损坏系统的可能性. 1:sudo的帮助信息如下: ...

  10. Hadoop HDFS编程 API入门系列之HdfsUtil版本1(六)

    不多说,直接上代码. 代码 package zhouls.bigdata.myWholeHadoop.HDFS.hdfs2; import java.io.FileOutputStream;impor ...