packages feed

haiji 0.3.1.0 → 0.3.2.0

raw patch · 33 files changed

+306/−2 lines, 33 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

+ content.tmpl view
@@ -0,0 +1,1 @@+{{ a_variable }}
+ example.py view
@@ -0,0 +1,11 @@+#!/usr/bin/python+from jinja2 import Environment, PackageLoader++if __name__ == '__main__':+    env = Environment(loader=PackageLoader('example', '.'))+    template = env.get_template('example.tmpl')+    print(template.render(+        a_variable = "Hello,World!",+        navigation = [ { 'href': 'content/a.html', 'caption': 'A'},+                       { 'href': 'content/b.html', 'caption': 'B'} ]+    ))
+ example.tmpl view
@@ -0,0 +1,16 @@+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">+<html lang="en">+<head>+  <title>My Webpage</title>+</head>+<body>+  <ul id="navigation">+    {% for item in navigation %}+    <li><a href="{{ item.href }}">{{ item.caption }}</a></li>+    {% endfor %}+  </ul>++  <h1>My Webpage</h1>+  {% include "content.tmpl" %}+</body>+</html>
haiji.cabal view
@@ -2,7 +2,7 @@ --  see http://haskell.org/cabal/users-guide/  name:                haiji-version:             0.3.1.0+version:             0.3.2.0 synopsis:            A typed template engine, subset of jinja2 description:         Haiji is a template engine which is subset of jinja2.                      This is designed to free from the unintended rendering result@@ -14,7 +14,37 @@ copyright:           Copyright (c) 2014-2019, Noriyuki OHKAWA category:            Text build-type:          Simple--- extra-source-files:+extra-source-files:  example.py+                     example.tmpl+                     content.tmpl+                     test/HTML_escape.tmpl+                     test/arith.tmpl+                     test/child.tmpl+                     test/comment.tmpl+                     test/comparison.tmpl+                     test/condition.tmpl+                     test/empty.tmpl+                     test/filter.tmpl+                     test/foreach.tmpl+                     test/foreach_else_block.tmpl+                     test/include.tmpl+                     test/included_0LF.tmpl+                     test/included_1LF.tmpl+                     test/included_2LF.tmpl+                     test/lf1.tmpl+                     test/lf2.tmpl+                     test/line_with_newline.tmpl+                     test/line_without_newline.tmpl+                     test/logic.tmpl+                     test/loop_variables.tmpl+                     test/many_variables.tmpl+                     test/parent.tmpl+                     test/range.tmpl+                     test/raw.tmpl+                     test/set.tmpl+                     test/string.tmpl+                     test/variables.tmpl+                     test/whitespace_control.tmpl cabal-version:       >=1.10  source-repository head
src/Text/Haiji/Syntax/AST.hs view
@@ -95,10 +95,17 @@   , parserStateInBaseTemplate = True   } +#if MIN_VERSION_base(4,13,0) newtype HaijiParser a =   HaijiParser   { unHaijiParser :: StateT ParserState Parser a+  } deriving (Functor, Applicative, Alternative, Monad, MonadState ParserState, MonadFail)+#else+newtype HaijiParser a =+  HaijiParser+  { unHaijiParser :: StateT ParserState Parser a   } deriving (Functor, Applicative, Alternative, Monad, MonadState ParserState)+#endif  runHaijiParser :: HaijiParser a -> Parser (a, ParserState) runHaijiParser p = runStateT (unHaijiParser p) defaultParserState
+ test/HTML_escape.tmpl view
@@ -0,0 +1,1 @@+{{ foo }}
+ test/arith.tmpl view
@@ -0,0 +1,27 @@+Pow+{{ 2**3 }}+{{ 2**31 }}+{{ 2**32 }}+{{ 2**63 }}+{{ 2**64 }}+{{ array|length**3**2 }}+{{ array|length**(3**2) }}+{{ (array|length**3)**2 }}+{{ 3**array|length**2 }}+{{ (3**array|length)**2 }}+{{ 3**(array|length**2) }}++Mul/Div/Mod+{{ 5//2 }}+{{ 5*2 }}+{{ 5//2*3 }}+{{ 5*2//3 }}+{{ 5%2 }}+{{ 5%2*3 }}+{{ 5*2%3 }}++Add/Sub+{{ 5+2 }}+{{ 5-2 }}+{{ 5+2-3 }}+{{ 5-2+3 }}
+ test/child.tmpl view
@@ -0,0 +1,6 @@+{% extends "test/parent.tmpl" %}+{% block title %}{{ super() }}{{ baz }}{{ super() }}{% endblock %}+{% block head %}+ {{ super() }}+ <style type="text/css"></style>+{% endblock %}
+ test/comment.tmpl view
@@ -0,0 +1,3 @@+test+{# comment #} #}+test
+ test/comparison.tmpl view
@@ -0,0 +1,27 @@+1 == 1: {{ 1 == 1 }}+1 == 2: {{ 1 == 2 }}+value == value: {{ value == value }}+value == 1: {{ value == 1 }}+(1 == 1) == (1 == 1): {{ (1 == 1) == (1 == 1) }}+(value == value) == (1 == 1): {{ (value == value) == (1 == 1) }}++1 != 1: {{ 1 != 1 }}+1 != 2: {{ 1 != 2 }}+value != value: {{ value != value }}+value != 1: {{ value != 1 }}+(1 != 1) != (1 != 1): {{ (1 != 1) != (1 != 1) }}+(value != value) != (1 != 1): {{ (value != value) != (1 != 1) }}++1 > 1: {{ 1 > 1 }}+1 > 2: {{ 1 > 2 }}+1 >= 1: {{ 1 >= 1 }}+1 >= 2: {{ 1 >= 2 }}+1 < 1: {{ 1 < 1 }}+1 < 2: {{ 1 < 2 }}+1 <= 1: {{ 1 <= 1 }}+1 <= 2: {{ 1 <= 2 }}++"test" == "test": {{ "test" == "test" }}+"test" == text: {{ "text" == text }}+"test" > "test": {{ "test" > "test" }}+"test" <= text: {{ "text" <= text }}
+ test/condition.tmpl view
@@ -0,0 +1,21 @@+{% if foo %}テスト{% endif %}++{% if foo %}真{% else %}偽{% endif %}++{% if foo %}+foo = True+{% if bar %}+bar = True+{% else %}+bar = False+{% endif %}+A+{% else %}+foo = Fasle+{% if baz %}+baz = True+{% else %}+baz = False+{% endif %}+B+{% endif %}
+ test/empty.tmpl view
+ test/filter.tmpl view
@@ -0,0 +1,2 @@+{{ value|abs }}+{{ array|length }}
+ test/foreach.tmpl view
@@ -0,0 +1,3 @@+{% for bar in foo %}+  ループ{{ bar }}+{% endfor %}
+ test/foreach_else_block.tmpl view
@@ -0,0 +1,9 @@+{% for bar in foo %}+  ループ{{ bar }}+{% else %}+  空+{% endfor %}++{% for bar in foo %}+  ループ{{ bar }}+{% endfor %}
+ test/include.tmpl view
@@ -0,0 +1,5 @@+{% for bar in foo %}+  {% include "test/included_0LF.tmpl" %}+  {% include "test/included_1LF.tmpl" %}+  {% include "test/included_2LF.tmpl" %}+{% endfor %}
+ test/included_0LF.tmpl view
@@ -0,0 +1,1 @@+{{ bar }}
+ test/included_1LF.tmpl view
@@ -0,0 +1,1 @@+{{ bar }}
+ test/included_2LF.tmpl view
@@ -0,0 +1,2 @@+{{ bar }}+
+ test/lf1.tmpl view
@@ -0,0 +1,1 @@+
+ test/lf2.tmpl view
@@ -0,0 +1,2 @@++
+ test/line_with_newline.tmpl view
@@ -0,0 +1,1 @@+foo
+ test/line_without_newline.tmpl view
@@ -0,0 +1,1 @@+foo
+ test/logic.tmpl view
@@ -0,0 +1,29 @@+{{ true and true }}+{{ true and false }}+{{ false and true }}+{{ false and false }}+{{ true and 1 == 1 }}++{{ true or true }}+{{ true or false }}+{{ false or true }}+{{ false or false }}+{{ true or 1 == 1 }}++{{ true or true and true }}+{{ true or true and false }}+{{ true or false and true }}+{{ true or false and false }}+{{ false or true and true }}+{{ false or true and false }}+{{ false or false and true }}+{{ false or false and false }}++{{ true and true or true }}+{{ true and true or false }}+{{ true and false or true }}+{{ true and false or false }}+{{ false and true or true }}+{{ false and true or false }}+{{ false and false or true }}+{{ false and false or false }}
+ test/loop_variables.tmpl view
@@ -0,0 +1,9 @@+{% for bar in foo %}+  {{ loop.index }}+  {{ loop.index0 }}+  {{ loop.revindex }}+  {{ loop.revindex0 }}+  {% if loop.first %}first{% endif %}+  {% if loop.last %}last{% endif %}+  {{ loop.length }}+{% endfor %}
+ test/many_variables.tmpl view
@@ -0,0 +1,17 @@+{{ a }}+{{ b }}+{{ c }}+{{ d }}+{{ e }}+{{ f }}+{{ g }}+{{ h }}+{{ i }}+{{ j }}+{{ k }}+{{ l }}+{{ m }}+{{ n }}+{{ o }}+{{ p }}+{{ q }}
+ test/parent.tmpl view
@@ -0,0 +1,11 @@+<html>+<head>+{% block head %}+  <title>{{ foo }}{% block title %}{% endblock %}</title>+{% endblock %}+</head>+<body>+  {{ bar }}+  {% block missing %}child missing this block{% endblock %}+</body>+</html>
+ test/range.tmpl view
@@ -0,0 +1,21 @@+{% for i in range(3) %}+{{ i }}+{% endfor %}++{% for i in range(1,3) %}+{{ i }}+{% endfor %}++{% for i in range(1,5,2) %}+{{ i }}+{% endfor %}++{% for i in range(value + 2) %}+{{ i }}+{% endfor %}++{% for a in array %}+{% for i in range(a) %}+{{ i }}+{% endfor %}+{% endfor %}
+ test/raw.tmpl view
@@ -0,0 +1,9 @@+int main() {+{% raw %}+  <ul>+  {% for item in seq %}+    <li>{{ item }}</li>+  {% endfor %}+  </ul>+{% endraw %}+}
+ test/set.tmpl view
@@ -0,0 +1,11 @@+{%- for y in ys %}+setにもスコープが存在する.変数を辞書に追加した後,+{%- set prev_loop = loop %}+ここから+{%- for x in xs %}+{{ prev_loop.index0 }} {{ loop.index0 }}+{%- endfor %}+ここまでをincludeと同じような扱いにする必要がある+{{ prev_loop.index0 }}+{%- endfor %}+ここにsetした変数を書いたらエラー
+ test/string.tmpl view
@@ -0,0 +1,6 @@+{{ 'test' }}+{{ "test" }}+{{ '\'"' }}+{{ "'\"" }}+{{ '\n' }}+{{ "\t" }}
+ test/variables.tmpl view
@@ -0,0 +1,8 @@+{{ foo }}+{{ _foo }}+{{ Foo }}+{{ F__o_o__ }}+{{ F1a2b3c }}+{{ true }}+{{ false }}+{{ 1 }}
+ test/whitespace_control.tmpl view
@@ -0,0 +1,5 @@+  {%- for item in seq -%}+    {{ item }}+  {%- endfor -%}++test