Template helper el

handlebars.el

Outputs html elements

{{#el}}content{{/el}}
{{{el content}}}
{{{el content=content}}}

Content is determined in the following way, stopping when it has a value

  1. Captured content If options.fn exists then the search stops here, even if the resulting value is empty
  2. Single positional params
  3. Multiple positional params Concatenated and assigned to content as an array
  4. content param
  5. el-content param
  6. contents param when passed as a string or array
  7. fallback param
Source:
Parameters:
Name Type Attributes Default Description
0 content <optional>

Element’s content

n string <optional>
<repeatable>

Further element content - concatenated with first content param

content content <optional>

Alternative content param

el-content content <optional>

Alternative content param

contents string | array | boolean <optional>

Multiple content items

If passed as true, the value of content is used

Otherwise, the value of contents is assigned to content if content has no value

class string | array <optional>

Element class

If passed as an array, its values are joined with a space

attributes object | string <optional>

Element attributes

Merged with any other params passed - with the other params taking precedence

If passed as a string, coerced into an object with its value set on the el-tag property

el-tag string | object <optional>
div

Tag name for element

el-escape boolean <optional>
true

Whether to escape the element’s content

el-wrap string | object <optional>

Tag name or attributes for wrapping content

el-wrap-all string <optional>

Tag name or attributes for wrapping multiple content items

el-wrap-outer string <optional>

Tag name or attributes for wrapping element

el-join= string <optional>

String to join content if it is an array but multiple content items have not been specified

el-reject regex <optional>
/^\s*$/

Pattern to match whether attribute’s value should cause the attribute to be skipped

el-split regex | string <optional>
/(\r\n|​\n\r|​\n|​\r)+/g

Pattern to use to split content

el-first-match boolean <optional>
false

Whether to output just the first non-empty content value

el-ternary boolean <optional>
undefined

Whether to output the value corresponding to the ternary value

NB. only two content values should be provided

el-force boolean <optional>
false

Force the output of an element even when it has no content

el-abort boolean <optional>
false

Whether to output just the content

el-abort-all boolean <optional>
false

Whether to output nothing at all

el-trim boolean <optional>
true

Whether to trim leading and trailing whitespace

el-fallback string <optional>

Fallback content to use if provided content has no value

el-fallback-class string <optional>

Fallback class to use if provided class has no value

el-fallback-{{prop}} string <optional>

Fallback property value to use if provided property has no value

el-content-before string <optional>

Additional content to insert before content

NB. this is inserted between the element and any wrapping element on the content

el-content-after string <optional>

Additional content to insert after content

NB. this is inserted between the element and any wrapping element on the content

el-params-content * <optional>

If content is a function, allows additional params to be passed to the function

el-content-params * <optional>

If content is an array and any of its elements is a function, allows additional params to be passed to the function

el-params-{{prop}} * <optional>

If attr {{prop}} is a function, this value is passed to the function

el-escape-{{prop}} boolean <optional>
undefined

Allows escaping to be performed at the individual attribute level

el-content-phrase boolean <optional>
false

Whether or not to use the content as a lookup key for handlebars.phrase

If passed, takes precedence over any existing escaping value