#4 new
Philipp Pirozhkov

create templating engine

Reported by Philipp Pirozhkov | November 7th, 2008 @ 05:22 AM

Tony have suggested to port Django templates to Reia

Comments and changes to this ticket

  • Philipp Pirozhkov

    Philipp Pirozhkov November 7th, 2008 @ 05:35 AM

    I've found some odd things i wouldn't clone in django's templating (http://docs.djangoproject.com/en...): template inheritance: base.html: ... ...

    index.html: {% extends "base.html" %} {% block title %}My amazing blog{% endblock %}

    Here, as we are planning to use view-controller, i see no need for such as we can just 1) pass a title value from controller, or 2) use nested controller-templates

    1) base.html: ... ... controllers/Base.re: module Base def index

    @title = "My amazing blog"
    
    

    this ain't good as we're mixing view with controller

    2) base.html:

    <title>{% render ~title %}</title>
    
    
    <div id="sidebar">
        {% render ~sidebar %}
    </div>
    
    

    and here we can use either ruby-merb style and render will insert title.html and sidebar.html here either use Yariv's erlyweb's style and pass subprocessing to controller/Sidebar.re, that will render views/sidebar/index.html The later is much more flexible, since we can pass valiables from a parent controller to subcontroller, add new ones etc

    Another point is escaping, it's odd to use {%, {, {{ in different cases. We can just use a single {, and distinct when we should insert statement result value and when we shouldn't: {if subject.length == 0}no subject{end} should be "no subject" if subject is empty {subject.length == 0} should be "true" if subject is empty

    I.e. 'if', 'case', 'for', 'end' should return an empty value, while other statements should be evaluated and the returned value should be inserted into page.

  • Philipp Pirozhkov

    Philipp Pirozhkov November 10th, 2008 @ 03:15 AM

    i18n

    Imagine we have a working web application:

    /apps/my_app/contollers/apple.re:

    
    module Apple
      def index(params, cookies, method)
        render #renders index.html
    

    /apps/my_app/views/apple/index.html:

    
    <html><body>
    <h1>Total {~apples:apples}</h1>
    {for apple in apples} <p>{apple}</p>{end}
    </body><html>
    

    Here we suggest that ~apples {~apple:apples} will be replaced with (assuming apples=3): - "3 apples" for english - "3 pommes" for french - etc

    And we are suggesting that "en-US" is a default, if there's nothing can be get from "language" cookie or "Accept-Language" http request header (in this order!).

    Thus, we can provide a dictionary in the following format (YAML): apps/my_app/i18n.yaml

    
    - apple !countable
      en-US: apple, apples
      fr-FR: pomme, pommes
    - banana !countable
     en-US: banana, bananas
     fr-FR: banane, bananes
    
  • Philipp Pirozhkov

    Philipp Pirozhkov December 21st, 2008 @ 04:16 AM

    This one can be closed, i'm implementing retem engine in scope of Ryan, and Herml will be ported sometimes soon too.

  • Taylor luk

    Taylor luk March 10th, 2009 @ 06:23 PM

    Hi there, Reia looks like a interesting language especially with recent indentless branch merged to master.

    I am the author of h2o template which is a django template port for php/ruby.. (www.h2o-template.org)

    What kind of templating style will fit Reia more ? Markaby or Django ?

    Let's discuss this matter further

  • Philipp Pirozhkov

    Philipp Pirozhkov March 11th, 2009 @ 01:14 AM

    Take a look at these:

    HAML for Erlang: http://github.com/kevsmith/herml - needs a wrapper to work in Reia Django Template for Erlang: http://github.com/archaelus/erlydtl - needs a wrapper and Retem - templating i began to write in Reia: http://github.com/pirj/ryan/tree...

    The latter has simpler syntax than DTL, and can be used for anything, not just HTML (that HAML disallows). Partially functional already (if/for/dot works), tests written (waiting for Tony to implement blocks to be able to run tests).

    Take at will! Your huge h2o experience can make a nice kick-start!

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Reia a dynamic scripting language for the Erlang virtual machine (BEAM)

People watching this ticket

Pages