Code Monkey home page Code Monkey logo

Comments (5)

amol- avatar amol- commented on July 18, 2024

In case XML syntax is desired shouldn't user just use XML mode? HTML allows for unclosed tags and actually deprecates self closing tags, but if I remember correctly kajiki XML mode does actually what you want to achieve.

from kajiki.

nphilipp avatar nphilipp commented on July 18, 2024

There are a couple of things that don't really cope well with the differences between HTML and XML (when delivered with an XML content type to the browser), e.g. some third-party Javascript modules expect tags to be uppercase in the DOM.

HTML5 explicitly allows self-closing void start tags, so I guess I'm in the clear there (except maybe for the suggested shortcut to using FontAwesome icons, i.e. a self-closing <i ... /> tag, but there's a licit alternative in <embed ... />).

Is there a way to use Kajiki XML mode in Turbogears and have it delivered as text/html? If so, I haven't found the way to do it.

from kajiki.

amol- avatar amol- commented on July 18, 2024

I'm not saying that self closed tags are wrong, jus that they are not required and they are actually just ignored for void elements, so kajiki is doing the right thing in HTML mode as those tags are self closing in any case.

Regarding how to switch kajiki to xml mode setting in turbogears templating.kajiki.force_mode = xml in your app_cfg.py should do what you are looking for. (See http://turbogears.readthedocs.io/en/latest/reference/config-options.html#tg.renderers.kajiki.KajikiRenderer) hope that helps!

from kajiki.

nphilipp avatar nphilipp commented on July 18, 2024

They're not required for HTML, but they're good if you want the rendered content not make stuff expecting XML go belly up (say the XML mode of your editor trying to balance out tags, or indent things intelligently 😉). I'm not expecting Kajiki to self-close all void start tags, only to preserve it if I do it in the template.

I'll try what you suggested about forcing Kajiki to use XML mode in TG, but as I said above, it needs to be delivered with content type text/html so client-side doesn't have the changes in DOM etc. that make other things (JS libraries) break.

from kajiki.

nphilipp avatar nphilipp commented on July 18, 2024

So, setting base_config['templating.kajiki.force_mode'] = 'xml' rendered void elements with self-closing start tags (not so with e.g. <script> but that is expected with what the HTML standard says about it), and delivers the page as text/html. That works for me and trims down this issue to "playing loose with whitespace" but that's not a huge problem (unless you optimize for bytes sent ;).

That leaves me only issue #21 before I can make the switch :).

from kajiki.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.