Socket
Socket
Sign inDemoInstall

@idrinth/simple-templating

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @idrinth/simple-templating

a very simple templating engine for browsers


Version published
Maintainers
1
Created

Readme

Source

Simple Templating

This small library provides minimal templating options for javascrpt in multiple enviroments, have a look at /min to see the options.

TypeStatus
BuildBuild Status
CoverageTest Coverage Codacy Badge
QualityCodacy Badge
MaintainabilityMaintainability

Values

assume the following values: {key: 'value', keys:{key:2}

{{key}} will be replaced by value, {{keys.key}} will be replaced by 2

Logic

logic blocks may contain other logic blocks.

IF

{%if check%}This shows if the boolean value of check is true.{{%end%}}
{%if !check%}This shows if the boolean value of check is false.{{%end%}}
{%if !check.property%}This shows if the boolean value of check.property is false.{{%end%}}

This does not support more than one variable. You can invert the check by adding an exclamation mark in front of the condition tho.

EACH

{%each list%}- {{_list.key}}: {{_list.value}}{%end%}

Each iterates over Objects and Arrays, exposing an object with the following properties within the loop:

  • key: the position in case of an array or the property name in case of other objects
  • pos: the position integer in the list, equal to list_key in the case of arrays
  • value: the value of the current item
  • even: a boolean, useful for conditions

The object's name is generated by prepending an underscrore to the name of the variable iterated over, so list will provide _list, list.sublist will provide _list#sublist.

Keywords

FAQs

Last updated on 09 Jun 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc