Skip to content
This repository has been archived by the owner on Feb 16, 2019. It is now read-only.

Demonstrates creating a custom tag that introduces scoped variables at compile-time

Notifications You must be signed in to change notification settings

marko-js-samples/scoped-variables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚨 This method is no longer recommended, please use tag parameters instead. 🚨

Marko Sample - scoped-variables

In this sample app we create a custom tag with the following usage:

<date-now var="now">
    The current time is $now.time.
    The current date is $now.dayOfWeek, $now.month $now.dayOfMonth, $now.year
</date-now>

The <date-now> custom tag introduces a scoped variable by declaring the vars property in the taglib/date-now/marko-tag.json file as shown below:

{
    "renderer": "./renderer",
    "@var": "identifier",
    "vars": [
        {
            "name-from-attribute": "var"
        }
    ]
}

The renderer for the <date-now> tag provides the value of the variable when invoking the renderBody(out, var1, var2) function as shown below:

var now = {
    time: ...,
    dayOfWeek: ...,
    ...
};

renderBody(out, now);

About

Demonstrates creating a custom tag that introduces scoped variables at compile-time

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published