Changeset 14137


Ignore:
Timestamp:
03/15/12 18:37:21 (12 years ago)
Author:
ramonb
Message:

cmt.py:

  • removed compatibility check

sara_cmt/cluster/templatetags/cmts_extras.py:

  • added compatibility check
  • see #4

this should do the trick

Location:
trunk/sara_cmt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sara_cmt/cmt.py

    r14126 r14137  
    311311        logger.error('Template does not exist: %s' % e)
    312312
    313        
    314     context['__template_outputfiles__'][context['output']]=rendered_string # temporary to be fwd-compatible
    315 
    316313    for outputfile, content in context['__template_outputfiles__'].items():
    317314        write_msg = 'Writing outputfile: %s' % outputfile
  • trunk/sara_cmt/sara_cmt/cluster/templatetags/cmts_extras.py

    r14136 r14137  
    166166               {% store variable %} # variable = '/path/to/file'
    167167    """
    168     try:
    169         # RB: split_contents respects quoted 'strings containing spaces'
    170         tag, path_str = token.split_contents()
    171     except ValueError:
    172         raise template.TemplateSyntaxError, '%r tag requires at least 1 argument' % tag
     168    definition = token.split_contents()
     169
     170    if len(definition) != 4 and len(definition) != 2:
     171        raise template.TemplateSyntaxError, '%r tag requires at least 1 arguments' % tag
     172
     173    tag = definition[0]
     174    path_arg = definition[1]
     175    #kw_as = definition[2]
     176    #kw_output = definition[3]
     177
     178    if len(definition) == 4:
     179
     180        #RB: 4 arguments means: {% store /path/filename as output %}
     181        #RB: old style: DONT try to resolve variable
     182        #RB: instead convert filename to quoted string
     183
     184        path_str = "'%s'" %path_arg
     185
     186    else:
     187
     188        #RB: 2 arguments can mean: {% store 'string' %}
     189        #RB: 2 arguments can mean: {% store variable %}
     190
     191        path_str = path_arg
    173192
    174193    # RB: parse the template thing until %endstore found
Note: See TracChangeset for help on using the changeset viewer.