Code Monkey home page Code Monkey logo

lua-handlebars's Introduction

Lua handlebars

A handlebars like template library for lua.

Helpers

format

Idempotent

stage: run

format string

Example

{{format "Hello there %q!" "World"}}

log

stage: run

Log to stdout

Example

<a>foo</a>{{log "Hello world"}}
<a>bar</a>

lower

Idempotent

stage: run

Lowercase string

Example

{{lower "UPPERCASE IS CRUISE CONTROL FOR COOL"}}

gsub

Idempotent

stage: run

Replaces all occurrences of a pattern in a string with a replacement string.

Example

{{gsub "all the space are belong to us" " " "" }}

unless

Block Idempotent

stage: code_generation

Unless block

Example

{{#unless nothing}}
foobar
{{/unless}}

err_log

stage: run

Log to stderr

if

Block Idempotent

stage: code_generation

If block

Example

{{#if isFoo}}<a>foo</a>
{{else}}<a>bar</a>
{{/if}}
{{#if isBar}}<div>bar</div>
{{else}}<div>foo</div>
{{/if}}

sub

Idempotent

stage: run

Extract substring

Example

{{sub "mylongstring" 3 -1}}

upper

Idempotent

stage: run

Uppercase string

Example

{{upper "I want to be uppercase"}}

each

Block Idempotent

stage: code_generation

Each block

Example

{{#each a}}<a>{{this}}</a>
{{/each}}

{{#each b}}<a>{{this}}</a>
{{else}}<a>No b</a>
{{/each}}

{{#each a}}<a>{{@key}}</a>
<a>{{@index}}</a>
{{else}}<a>No b</a>
{{/each}}

with

Block Idempotent

stage: code_generation

With block

Example

{{#with a}}
<a> name: {{name}}</a>
<a> address: {{addr}}</a>
{{/with}}

gmatch

Block Idempotent

stage: code_generation

Iterate trough a matches of a pattern see lua patterns

Example

{{#gmatch "one, two, three" "%w+"}}
{{this}}
{{/gmatch}}

Requiremnets

lua-handlebars's People

Contributors

miniwoffer avatar

Stargazers

 avatar

Watchers

Bjørnar Ness avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.