1.2.2 • Published 7 years ago

junglet v1.2.2

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

junglet

junglet is a node template engine. The purpose of it is to allow viewing the file in the browser without parsing it and then replace parts with data. This is to allow frontend developers to develop templates with lorem ipsum text that is then replaced with real data.

This is done with a mixture of DOM attributes (jt-content, jt-each) and "junglet expressions" ({j t}). The value of these expressions are evaluated with safe-eval and the resulting value is rendered.

You can import other files with <!-- import filename -->. These will be imported before all expressions are evaluated.

This is primarily used for Jungledrum. See jungledrum for more information.

JavaScript Style Guide

Install

npm install junglet

Syntax

<!-- import header.html -->
<h1 jt-content="header">Hello world</h1>
<p jt-content="content">Lorem ipsum</p>
<p jt-content="nested.value">Nested value</p>
<p>First element of list is <span jt-content="list[0]"></span></p>
<ul>
  <li jt-each="list" jt-content="self"></li>
</ul>
<ul>
  <li jt-each="list">junglet expression in content {j self t}</li>
  <li jt-remove>This is just lorem ipsum which will be removed</li>
</ul>
<p class="{j specialClass t}">junglet expression in attribute</p>

API

var junglet = require('junglet')

var locals = {
  header: 'Abc',
  content: 'Abc',
  nested: { value: 'Abc' },
  list: ['a', 'b'],
  specialClass: 'special-class'
}

// Render
var html = junglet.render('template string', locals)
var html = junglet.renderFile('filename.junglet.html', locals)
1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago