'''
The default rendering engine, process yaml with the jinja2 templating engine

This renderer will take a yaml file with the jinja2 template and render it to a
high data format for salt states.
'''

# Import Python Modules
import os
import logging
import warnings

# Import Salt libs
from salt.utils.jinja import get_template
from salt.utils.yaml import CustomLoader, load

log = logging.getLogger(__name__)

def render(template_file, env='', sls=''):
    '''
    Render the data passing the functions and grains into the rendering system
    '''
    if not os.path.isfile(template_file):
        return {}

    passthrough = {}
    passthrough['salt'] = __salt__
    passthrough['grains'] = __grains__
    passthrough['pillar'] = __pillar__
    passthrough['env'] = env
    passthrough['sls'] = sls

    template = get_template(template_file, __opts__, env)

    yaml_data = template.render(**passthrough)
    with warnings.catch_warnings(record=True) as warn_list:
        data = load(yaml_data, Loader=CustomLoader)
        if len(warn_list) > 0:
            for item in warn_list:
                log.warn("{warn} found in {file_}".format(
                        warn=item.message, file_=template_file))
        return data

@@ -367,16 +367,88 @@
 er, load
+%0Afrom salt.exceptions import SaltRenderError%0Aimport salt.utils.templates
 %0A%0Alog = 
@@ -683,59 +683,117 @@
     
-passthrough = %7B%7D%0A    passthrough%5B'salt'%5D = 
+tmp_data = salt.utils.templates.jinja(%0A            template_file,%0A            True,%0A            salt=
 __salt__
 %0A   
@@ -792,37 +792,29 @@
 lt__
+,
 %0A    
-passthrough%5B'
+        
 grains
-'%5D = 
+=
 __gr
@@ -823,37 +823,56 @@
 ns__
+,
 %0A    
-passthrough%5B'
+        opts=__opts__,%0A            
 pillar
-'%5D = 
+=
 __pi
@@ -881,126 +881,204 @@
 ar__
+,
 %0A    
-passthrough%5B'env'%5D = env%0A    passthrough%5B'sls'%5D = sls%0A%0A   
+        env=env,%0A            sls=sls)%0A    if not
  t
-e
 mp
-late = get_template
+_data.get('result', False):%0A        raise SaltRenderError
 (t
-e
 mp
-late_file, __opts__, env)%0A
+_data.get('data',%0A            'Unknown render error in yaml_jinja renderer'))
 %0A   
@@ -1095,37 +1095,23 @@
  = t
-e
 mp
-late.render(**passthrough)
+_data%5B'data'%5D
 %0A   

move yaml_jinja to standard template renderer