Skip to content

Custom attribute for Marko to more easily render nested body content

Notifications You must be signed in to change notification settings

kristianmandrup/marko-tag-body

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

marko-dynamic-tag

Installation

npm install marko-dynamic-tag --save

Requirements

Currently requires this marko fork.

A PR has been submitted to enable a few required hooks ;)

Usage

The magic is in the special tag: tag-name which can be set to an expression that will dynamically, runtime replace the tag name!!

<dynamic-tag tag-name='h$data.lv' class='ui header'>hello world</dynamic-tag>

NOTE: If the value of the tag-body is left blank then it will default to data.renderBody.

template.renderSync({
        lv: '1'
    });

Output:

<h1 class='ui header'>hello world</h1>
template.renderSync({
        renderBody: function(out) {
            out.write('My body content')
        }
    });

Output:

<div>
    <h1>Hello World</h1>
    <p>
        My body content
    </p>
</div>

About

Custom attribute for Marko to more easily render nested body content

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%