Jade之Interpolation
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}
在属性那一章的特殊属性中曾提到,类似<这样的特殊符号编译后将为<。同样在使用#{val}的时候,若val变量的值含有这些特殊符号的时候,编译也会变成<这样的形式。
为了避免出现如上形式,可以采用!{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的更多相关文章
- pug模板引擎(原jade)
前面的话 为什么要引入pug,pug有什么特别之处呢?有一些嵌套层次较深的页面,可能会出现巢状嵌套,如下图所示 在后期维护和修改时,一不小心少了一个尖括号,或者某个标签的开始和闭合没有对应上,就会导致 ...
- Jade模板引擎让你飞
写在前面:现在jade改名成pug了 一.安装 npm install jade 二.基本使用 1.简单使用 p hello jade! 渲染后: <p>hello jade!</p ...
- emmet,jade,haml, slim,less,sass,coffeescript等的实战优缺点
摘要: 文章背景,来自于群内周五晚上的一次头脑风暴式的思维碰撞交流活动. 随着前端技术的蓬勃发展, 各种新技术随着生产力的需要不断的涌入我们的视野, 那今天探讨的话题是这些新时代的前端兵器谱: 一. ...
- Vue ES6 Jade Scss Webpack Gulp
一直以来非常庆幸曾经有翻过<代码大全2>:这使我崎岖编程之路少了很多不必要的坎坷.它在软件工艺的话题中有写到一篇:"首先是为人写程序,其次才是机器(Write Programs ...
- Jade 模板引擎使用
在 Express 中调用 jade 模板引擎 jade 变量调用 if 判断 循环 Case 选择 在模板中调用其他语言 可重用的 jade 块 (Mixins) 模板包含 (Includes) 模 ...
- jade模板引擎
最近用jade写了点东西,觉得挺有趣的,是一个有意思的模板引擎. 比如说,像这样的结构的html <span> <i class="icon-edit">& ...
- OPEN CASCADE BSpline Curve Interpolation
OPEN CASCADE BSpline Curve Interpolation eryar@163.com Abstract. Global curve interpolation to point ...
- OpenCASCADE Interpolation - Lagrange
OpenCASCADE Interpolation - Lagrange eryar@163.com Abstract. Power basis polynomial is the most simp ...
- 在webstorm设置File watcher for Jade
用Jade模板引擎写html确实方便,元素不用闭合,很多种简写的方法. 为了要知道自己写的对不对,就要用到jade -w命令监控jade文件,只要变化就编译. 现在用webstorm写代码的超多,可以 ...
随机推荐
- sp_help 快速查看表结构、视图信息
sp_helptext: 是MS SQL Server的一个系统存储过程,可以通过它来查看存储过程或者视图.函数源码 示例:sp_helptext viewName (viewName 即要查询的存 ...
- HDU2047
http://acm.hdu.edu.cn/showproblem.php?pid=2047 对于这道题,我就从后面向前面考虑. 当第n个是o的话,那么n-1 只可以取e或者f,如果n是e或者f的话, ...
- finder文件目录跳转快捷键
finder文件目录跳转快捷键 command+shift+G
- Spring项目解决Post乱码
Java EE解决Post乱码:在web.xml中加入: <filter> <filter-name>encodingFilter</filter-name> &l ...
- Linux网络常用指令
5.1 网络参数设定使用的指令 ifconfig 查询 设定网络卡与 IP 网域等相关参数: ifup, ifdown 这两个档案是 script,透过更简单的方式来启动网络接口: route 查 ...
- PowerDesigner15中定义varbinary(max)列
PowerDesigner15 概念数据模型(Entity)中要定义数据类型为varbinary(max)的特性(Attribute),应将数据类型(Data Type)选择为other,在代码(Co ...
- ---解决git pull 后出现冲突的解决方法
0. git statusOn branch masterYour branch and 'origin/master' have diverged,and have 1 and 3 differen ...
- UVa 414 - Machined Surfaces
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...
- Linux下查找文件命令——find
find [在哪个目录下查找] -name <文件名> 1.场景:当你知道了某个文件的文件名,而不知道这个文件放到哪个文件夹,甚至是层层套嵌的文件夹里, 也可以使用find命令来查找,如: ...
- Composite(组合)--对象结构型模式
1.意图 将对象组合成树形结构以表示“部分-整体”的层次结构.Composite使得用户对单个对象和组合对象的使用具有一致性. 2.动机 可以组合多个简单组件以形成一些较大的组件,这些组件又可以组合成 ...