Skip to main

Utility Macros

content/_includes/utility.macros.njk

Utilities can be used just about anywhere, and that’s why we love them.


Attributes

attr_if()

Pass in an attribute name and value. If the value is not falsey, we’ll display the attribute with appropriate value when necessary.

Params:

  • attr {string}

    The attribute name

  • value {string | boolean} = none

    The value of the attribute. “True” or “true” (string or boolean) will output the attribute without any value, while falsey values will not output any attribute.

show_attrs()

Render a dictionary of attribute/value pairs into HTML-ready attributes.

Params:

  • attrs {object}

style_if()

Render a dictionary of property/value pairs into an HTML-ready style attribute.

Params:

  • style {object}

Links

links

main_action()

Generate a “main-action” link, generally one-per-section.

Params:

  • content {string}
  • url {url} = none

Time

datetime()

Format dates and times for posts

Params:

  • start {date}
  • end {date | none}
  • format {string | date-format} = long
  • is_pubdate {boolean}

See Also: