mercurial/templater.py
branchstable
changeset 25471 7298da81f5a9
parent 24949 890845af1ac2
child 25490 ad14fb602e5e
child 25562 9452112c8eb0
equal deleted inserted replaced
25460:bd4bcfa48c9e 25471:7298da81f5a9
   324 
   324 
   325     key = args[1][0](context, mapping, args[1][1])
   325     key = args[1][0](context, mapping, args[1][1])
   326     yield dictarg.get(key)
   326     yield dictarg.get(key)
   327 
   327 
   328 def _evalifliteral(arg, context, mapping):
   328 def _evalifliteral(arg, context, mapping):
   329     t = stringify(arg[0](context, mapping, arg[1]))
   329     # get back to token tag to reinterpret string as template
   330     if arg[0] == runstring or arg[0] == runrawstring:
   330     strtoken = {runstring: 'string', runrawstring: 'rawstring'}.get(arg[0])
       
   331     if strtoken:
   331         yield runtemplate(context, mapping,
   332         yield runtemplate(context, mapping,
   332                           compiletemplate(t, context, strtoken='rawstring'))
   333                           compiletemplate(arg[1], context, strtoken))
   333     else:
   334     else:
   334         yield t
   335         yield stringify(arg[0](context, mapping, arg[1]))
   335 
   336 
   336 def if_(context, mapping, args):
   337 def if_(context, mapping, args):
   337     """:if(expr, then[, else]): Conditionally execute based on the result of
   338     """:if(expr, then[, else]): Conditionally execute based on the result of
   338     an expression."""
   339     an expression."""
   339     if not (2 <= len(args) <= 3):
   340     if not (2 <= len(args) <= 3):