[ANN] OteraEngine.jl: Template Engine for Julia

What is OteraEngine?

OteraEngine is light and powerful Template Engine. The syntax is based on jinja2 and ‘Julia Code Block’, which makes you available to write Julia code directly in templates, is added.
Now, in v0.4.0, this package is stabilized.
Please see docs for details.

Features

This is the list of features:

  • Jinja like syntax: syntax is based on jinja and arranged for Julia
  • autospace: option to control white spaces automatically
  • JuliaCodeBlock: you can directly write Julia code in templates
  • simple, and pure: This package is written in pure Julia and depends on only few Standard libraries

Example

Template:

<html>
    <head><title>MyPage</title></head>
    <body>
        10 * sqrt(2) is : {<
            a = 10
            b = sqrt(2)
            round(a * b)
        +>}
        {% raw %}
        This is the test for raw block
        {% you can write block inside of raw %}
        {% endraw %}
        {% for i in 1 : 10 %}
        {% if i < 4 %}
        {{i}} is smaller than 4
        {% elseif i < 8 %}
        {{i}} is bigger than 3 and smaller than 8
        {% else %}
        {{i}} is bigger than 7
        {% end %}
        {% end %}
        {% let age = 15 %}
        and your age is {{ age }}.
        {% end %}
    </body>
</html>

Output:

<html>
    <head><title>MyPage</title></head>
    <body>
        10 * sqrt(2) is :14.0
        This is the test for raw block
        {% you can write block inside of raw %}
        1 is smaller than 4
        2 is smaller than 4
        3 is smaller than 4
        4 is bigger than 3 and smaller than 8
        5 is bigger than 3 and smaller than 8
        6 is bigger than 3 and smaller than 8
        7 is bigger than 3 and smaller than 8
        8 is bigger than 7
        9 is bigger than 7
        10 is bigger than 7
        and your age is 15.
    </body>
</html>
11 Likes