rogain-core-helpers
Core helpers for Rogain templates.
Helpers
Frame
Alias and create inline variables.
{intro} {friend}
My friend's name is Buckle
Children
Provides an outlet in a component that can be used to compose components.
Each
Returns a tree of the data
mapped to children. Each child can access the current element with the @item
(or as
attribute) properties and the current index with @index
.
{@result.title} {@result.excerpt}
Attributes
data
Variable. Array.
as
String. Defines the local variable for accessing each element in data
. Defaults to @item
.
Defined
Returns children if data
is an non-empty Array or Object ([0, 1]
, {x:1,y:3}
) or defined variable. If the <Else />
branch is defined, it will be returned when data
is empty or undefined.
Attributes
data
Variable or Expression.
Empty
Returns children if data
is an empty Array or Object ([]
, {}
) or undefined variable. If the <Else />
branch is defined, it will be returned when data
is non-empty and defined.
No results.
Attributes
data
Variable or Expression.
If
Returns it's children if data
to value
are equal. If the <Else />
branch is defined, it will be returned when data
and value
are not equal.
If value
is not defined, If
will have the same behavior as Defined
.
Attributes
data
Variable or Expression.
value
Variable or Expression. Optional.
Unless
Returns it's children if data
to value
are not equal. If the <Else />
branch is defined, it will be returned when data
and value
are equal.
If value
is not defined, Unless
will have the same behavior as Empty
.
Attributes
data
Variable or Expression.
value
Variable or Expression. Optional.
Range
Returns children if data
is between min
and max
. If the <Else />
branch is defined, it will be returned when data
is out of range.
Omitting min
or max
will default to -Infinity
and Infinity
respectively.
<!-- Top 3 --> {@item.title} {@item.excerpt} <!-- The rest --> {@item.title}
Attributes
data
Variable or expression.
min
Number. Optional.
max
Number. Optional.
Else
Implicit helper. Can be used with If
, Unless
, Defined
, Empty
, Range
. Used to denote an inverse branch.
<!-- If Branch --> <!-- Else Branch -->
Else helper is not meant to be called as a block, it's used to split trees inside other helpers.
Install
With npm do:
npm install rogain-core-helpers
License
MIT