Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kajiki templating #77

Open
alexbodn opened this issue Oct 20, 2016 · 2 comments
Open

kajiki templating #77

alexbodn opened this issue Oct 20, 2016 · 2 comments

Comments

@alexbodn
Copy link

alexbodn commented Oct 20, 2016

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

@amol-
Copy link
Member

amol- commented Oct 20, 2016

the @expose should have content_type='application/xhtml+xml'

Newly quickstarted 2.3 apps come configured in a HTML5 way, so they serve as text/html. Making xhtml the default would force the majority of users to change this.

KajikiRenderer.call should also take **kwargs, that will be received as the render_params passed to @expose.

That's actually already supported in 2.3, but was undocumented, has been documented in an August commit still unreleased :)

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.

That looks useful, I'll try to check Tw2 integration as soon as the tw2 patch is approved.

@alexbodn
Copy link
Author

alexbodn commented Nov 5, 2016

the far i could understand, the content type would be needed to validate as xhtml 5.
this is the format requested from the template designer.

i saw your submits on tw2.core ;) .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants