@jolie/liquid

1.0.1 • Public • Published

LiquidService

LiquidService is a Jolie service that exposes the rendering API of the Liquid template engine as implemented by the Liqp---plus a few tricks to make it more Jolie-friendly 😉.

Install

jpm add @jolie/liquid

Usage example

from @jolie.liquid.main import Liquid
from console import Console

service main(){

  embed Console as Console
  embed Liquid as Liquid

  main {
    template = 
    "{% case language %}"
    + "{% when 'Danish' %}Hej"
    + "{% when 'French' %}Salut"
    + "{% when 'Italian' %}Ciao"
    + "{% when 'Spanish' %}Hola"
    + "{% when 'Russian' %}привет"
    + "{% when 'Thai' %}สวัสดี"
    + "{% else %}Hi"
    + "{% endcase %}"
    + ", {{ name }}"

    data << { 
      name = "Saverio" 
      language = "Italian"
    }
    renderDocument@Liquid({ 
      data << data,
      template = template,
      format = "jolie" 
      })( s )
    println@Console( s )()
  }
}

Jolie Interface

/**
* Loaded templates are useful when sub-templates are necessary
* in the main template (the one used in the renderDocument operation).
* From any template , it is possible to pass data to a loaded template
* with the useTemplate filter, e.g., {{ data | useTemplate: "myTemplate" }}
*/
type LiquidRequest: void {
  .data: string | undefined //< either a json string or a jolie value (set accordingly the `format` node) 
  .format: string( regex( "json|jolie" ) )
  .template: string
}

type LoadRequest: void {
  .template: string
  .name: string
}

Package Sidebar

Install

npm i @jolie/liquid

Weekly Downloads

0

Version

1.0.1

License

LGPL 2.1

Unpacked Size

3.35 MB

Total Files

8

Last publish

Collaborators

  • kicito
  • fmontesi
  • bmaschio77
  • luis.antonio
  • thesave
  • klag