代码拉取完成,页面将自动刷新
set
, etc) are parsed in correct order. gh-495set
tag. gh-499, gh-502macro
argument names colliding with context variable names. gh-457$
. gh-455fs
loader should take cwd
as default base path. gh-419varControls
, tagControls
, cmtControls
). gh-415null
should yield empty string when resolving variable. gh-408date
filter argument. gh-427, gh-432if
and elseif
throw a better error message when a tag body is omitted. gh-425null
object. gh-471loop
variables work correctly in nested loops. gh-433for
loop variables on objects. gh-409include
files when loaders have base paths. gh-407set
tag to set keys on objects with bracket and dot-notation. gh-388groupBy
filter from swig-extras. gh-383swig.run
filepath
arg is always optional. gh-402date
filter N
option returns correct number. gh-375Migrating from v0.x.x? View the Migration Guide
variable
blocks are no longer auto-escaped. gh-309set
tag assigns to the local context, allowing setting within for
loops, etc. gh-303include
tag now accepts only
(and is preferred, if possible). gh-240swig.version
and -v
to cliraw
filter. Use safe
.import
and macro
tags to be outside of blocks. gh-299macro
output. gh-297safe
to disable auto-escaping. gh-294{% for k,v ... %}
tag syntax assigned variables backwards.include
paths on windows. gh-295swig.compileFile
runs callback template is found in cache. gh-291sort(true)
.compileFile
and renderFile
operations. gh-283sort
.parser.on('start'|'end'...
options. gh-274swig.init
method.swig.addFilter
swig.addTag
swig.compileFile
returns a function that renders templates, not an objectswig.renderFile
.extends
, import
, and include
now reference files with relative paths from the current file (info).extends
may no longer accept variables (info).else if
tag is now elseif
or elif
.only
argument from include
._
, $
to start var names in templates.{{
, }}
, etc, can be customized).compile
, run
, and render
(Lets you pre-compile templates into JS functions for client-side delivery).spaceless
tag gh-193for
. gh-232parentBlock
argument from tags.extends
tag parametersignore missing
tokens to include tagwith context
to only work if context
is an objectautoescape
tag controls no longer 'yes' or 'no'. Use true
and false
N
and w
gh-59extensions
for 3rd party extension access in custom tags gh-44empty
tag in for
loops is now else
gh-49forloop
vars to loop
closes gh-47include
tag's with
and only
args documentation gh-50parent
tag would not render when called within tags gh-41include
inside base template block
tags gh-43set
tag to set values to numbers gh-45set
tag for booleans using too many checksdate
filter gh-27.raw
tag.date('f')
for 10am times.date('r')
returns in UTC date format. This is more correct tospec RFC2822, per php.net/date.add
when adding numbers/numbers+strings together.z
, W
, t
, L
, o
, B
, and c
.filter
tag.swig.render
and swig.fromString
.swig.fromFile
is now swig.compileFile
.swig.init()
will clear template cache.swig.init()
is now optional for browser mode with no custom settings.|
characters in filter arguments. gh-22make browser
will build Swig for use in major browsers. gh-3escape
filters. gh-19{% import foo as bar %}
tag for importing macros.raw
filter to force variable to not be escaped.escape
and e
filters to force variable to be escaped.if
, else
, and else if
tags support all JS-valid if-syntaxes + extra operators.default
filter for undefined variables. closes gh-18include
tags accept context variables instead of just strings.locals
for express support.length
filter returns length of objects (number of keys).{% set ... %}
tag.if
blocks.forloop.first
in for
blocks.forloop.last
in for
blocks.forloop.key
in for
blocks.{% empty %}
in for
blocks.else if ...
within if
blocks.else
within if
blocks.if
statements allow filters applied to operands.for
loops allow filters applied to the object that will be iterated over.allowErrors
flag will allow errors to be thrown and bubbled up. Default to catch errors.add
, addslashes
, and replace
filters.endblock
, endif
, endfor
, etc...first
, last
, and uniq
filters此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。