marko-tag-body

1.1.1 • Public • Published

marko-tag-body

Installation

npm install marko-tag-body --save

Usage

<div>
    <h1>Hello World</h1>
    <p tag-body=(data.renderBody || data.body)>
    </p>
</div>
template.renderSync({
        body: 'My body content'
    });

Output:

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

A renderBody() function is passed as part of the input to the template:

template.renderSync({
        renderBody: function(out) {
            out.write('My body content')
        }
    });

Then the output would be the following:

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

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

<div>
    <h1>Hello World</h1>
    <p tag-body>
    </p>
</div>
template.renderSync({
        renderBody: function(out) {
            out.write('My body content')
        }
    });

Output:

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.1
    1
  • 1.1.0
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i marko-tag-body

Weekly Downloads

1

Version

1.1.1

License

ISC

Last publish

Collaborators

  • austinkelleher
  • dylanpiercey
  • mlrawlings
  • pnidem