Skip to content

Template Variables

Jorge Castro edited this page Jan 14, 2021 · 10 revisions

Variables

Show variables

Tag Note Example
{{$variable}} It shows a variable or evaluates a function. The result is escaped (i.e. encoding special characters) {{$country}}
{!!$variable!!} It shows a variable or evaluates a function. The result is not escaped. {!!$country!!}
{{-- text --}} It is a comment (the content inside is not evaluated) {{-- hi there --}}
@{{$variable1}} show the value of the content directly (not evaluated, useful for js) @{{$country}}
{{ $name or 'Default' }} value or default {{$country or "no country"}}

@compilestamp($format='')

It shows the current date of the compiled template

@compileStamp() // returns the current date and time as "Y-m-d H:i:s"
@compileStamp('d') // returns the current date AND TIME AS "d" (day)

@viewname($type='')

It shows the name of the template

@viewname('compiled') // the full filename of the compiled file
@viewname('template') // the full filename of the template
@viewname('') // the name of the filename

@set

It sets a variable inside the template. Technically, it could allow any PHP expression.

@set($variable=[value])

@set($variable=2000)
@set($variable='2222')
@set($variable=$othervar)
@set($variable=$aa['aaa'])
@set($variable=444+555)
@set($variable=somefn('hi'))

@set($variable) is equals to @set($variable=$variable+1)

  • $variable defines the variable to add. If not value is defined and it adds +1 to a variable.
  • value (option) define the value to use.