Skip to content

webcore-no/lua-handlebars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published