diff options
author | florent <florent.pigout@gmail.com> | 2011-07-09 00:33:26 (GMT) |
---|---|---|
committer | florent <florent.pigout@gmail.com> | 2011-07-09 00:33:26 (GMT) |
commit | 0767eedcd06485f30ee6b00df348b22847c7c7ad (patch) | |
tree | de339586453b0b638889ec607f4ded7de2edc05a /templates/_helpers.html | |
parent | 89198c864831bea0a17f136b897aebc59f606166 (diff) |
make the flask based tools more clean for a nicer use -> move requirement to lib dir + limit import code to the minimumHEADmaster
Diffstat (limited to 'templates/_helpers.html')
-rw-r--r-- | templates/_helpers.html | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/templates/_helpers.html b/templates/_helpers.html new file mode 100644 index 0000000..f541437 --- /dev/null +++ b/templates/_helpers.html @@ -0,0 +1,51 @@ +{% macro link_to(text, endpoint) -%} + <a href="{{ url_for(endpoint, **kwargs) }}">{{ text }}</a> +{%- endmacro %} + +{% macro options(_, name, option_list, current, action) -%} + <div class='{{ name }}'> + <h1>{{ _(name) }}</h1> + <form name='{{ name }}' action='{{ action }}' method="post"> + {% for opt in option_list %} + <input type='radio' name='{{ name }}' value='{{ opt }}' {% if opt == current %}checked{% endif %} />{{ _(opt) }}<br /> + {% endfor %} + </form> + <script> + <!-- + $(document).ready(function() { + $(".{{ name }} input[type='radio']").change( function() { + $(".{{ name }} form").submit(); + }); + }); + --> + </script> + </div> +{%- endmacro %} + +{% macro options_ajax(_, name, option_list, current, action) -%} + <div class='{{ name }}'> + <h1>{{ _(name) }}</h1> + <form name='{{ name }}'> + {% for opt in option_list %} + <input type='radio' name='{{ name }}' value='{{ opt }}' {% if opt == current %}checked{% endif %} />{{ _(opt) }}<br /> + {% endfor %} + </form> + <script> + <!-- + $(document).ready(function() { + $(".{{ name }} input[type='radio']").change( function() { + $.ajax({ + url: '{{ action }}', + type: 'POST', + data: ({ '{{ name }}' : $(this).val()}), + success: function(data) { + var _el = $('#result'); + _el.html(data.word); + } + }); + }); + }); + --> + </script> + </div> +{%- endmacro %} |