Skip to content

kajiki templating #77

Description

@alexbodn

hello friends,
and a big thank for turbogears.
i've made and being maintaining a tg 2.1.5 app, that is currently in upgrading process to html5/kajiki.
please allow me to give back, and implement my patches for code and documentation.
indeed, upgrading to tg 2.3 would be good too, but my tg is quite patched and extended, that would need some more work.

  1. output validation:
    the @expose should have content_type='application/xhtml+xml'
    i see in the tg 23 code this is the engines variables, but i have no app to try it myself.
    the output may be validated at https://html5.validator.nu
    it's been done before the actual render, see below.
  2. parameters:
    KajikiRenderer.call should also take **kwargs, that will be received as the render_params passed to @expose.
    in render_template, i did the following to produce a DOCTYPEless output, by the genshi parameter doctype=None. if you have a better way, go ahead, please.
        load_parms = dict()                                                     
        if 'doctype' in kwargs and kwargs['doctype'] is None:                   
            load_parms['is_fragment'] = True                                    
        template = template_vars['app_globals'].kajiki_loader.load(             
            template_name, **load_parms)                                        
        response.headers['Content-Type'] = \                                    
            'application/xhtml+xml; charset=%s' % response.charset              

  1. tw2.
    as my kajiki widgets and other kajiki templates share the same kajiki modules, i made a small patch to add_tosca2_middleware, so that the template path will be the same in imports.
        self.custom_tw2_config.update(                                          
            paths_templates=self.paths.templates,.                              
        )                                                                       
        default_tw2_config.update(self.custom_tw2_config)                       

this would need a patch that i've already submitted in tw2.core.

  1. the migration documentation at http://turbogears.readthedocs.io/en/latest/turbogears/kajiki-xml-templates.html
    my aim is at html5, hence all templates should be this will even be nice for code editors. tw2 widgets do not add the doctype, and regular @expose may have
    render_params=dict(doctype=None.) to have no doctype.
    all templates should have xmlns="http://www.w3.org/1999/xhtml" in their .
    regular templates extended by py:extends should have py:strip="1".
    if a py:block is been defined within a tag, that tag should not be py:strip="1", but py:if="0".

hope that helps,
alex

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions