@ -535,7 +535,7 @@ class Templar:
if isinstance ( variable , string_types ) :
if isinstance ( variable , string_types ) :
result = variable
result = variable
if self . is_ template( variable ) :
if self . is_ possibly_ template( variable ) :
# Check to see if the string we are trying to render is just referencing a single
# Check to see if the string we are trying to render is just referencing a single
# var. In this case we don't want to accidentally change the type of the variable
# var. In this case we don't want to accidentally change the type of the variable
# to a string by using the jinja template renderer. We just want to pass it.
# to a string by using the jinja template renderer. We just want to pass it.
@ -631,7 +631,7 @@ class Templar:
return variable
return variable
def is_template ( self , data ) :
def is_template ( self , data ) :
''' lets us know if data has a template'''
''' lets us know if data has a template'''
if isinstance ( data , string_types ) :
if isinstance ( data , string_types ) :
return is_template ( data , self . environment )
return is_template ( data , self . environment )
elif isinstance ( data , ( list , tuple ) ) :
elif isinstance ( data , ( list , tuple ) ) :
@ -644,7 +644,26 @@ class Templar:
return True
return True
return False
return False
templatable = _contains_vars = is_template
templatable = is_template
def is_possibly_template ( self , data ) :
''' Determines if a string looks like a template, by seeing if it
contains a jinja2 start delimiter . Does not guarantee that the string
is actually a template .
This is different than ` ` is_template ` ` which is more strict .
This method may return ` ` True ` ` on a string that is not templatable .
Useful when guarding passing a string for templating , but when
you want to allow the templating engine to make the final
assessment which may result in ` ` TemplateSyntaxError ` ` .
'''
env = self . environment
if isinstance ( data , string_types ) :
for marker in ( env . block_start_string , env . variable_start_string , env . comment_start_string ) :
if marker in data :
return True
return False
def _convert_bare_variable ( self , variable ) :
def _convert_bare_variable ( self , variable ) :
'''
'''