文档类型
xxxxxxxxxx
xxxxxxxxxx
文档类型快捷方式
常用文档类型有快捷方式
- doctype html
- doctype xml
- doctype transitional
- doctype strict
- doctype frameset
- doctype 1.1
- doctype basic
- doctype mobile
- doctype plist
自定义文档类型
你也可以使用你自己的自定义文档类型
xxxxxxxxxx
xxxxxxxxxx
文档类型选项
除了在输出中进行缓冲之外,Pug 中的文档类型还可以通过其他方式影响编译。例如,自闭合标签以 />
或 >
结尾取决于是否指定了 HTML 或 XML。 布尔属性 的输出也可能受到影响。
如果由于某种原因,无法使用 doctype
关键字(例如,仅渲染 HTML 片段),但仍然希望指定模板的文档类型,则可以通过 doctype
选项 来实现。
var pug = require('pug');
var source = 'img(src="foo.png")';
pug.render(source);
// => '<img src="foo.png"/>'
pug.render(source, {doctype: 'xml'});
// => '<img src="foo.png"></img>'
pug.render(source, {doctype: 'html'});
// => '<img src="foo.png">'