Hacker News new | ask | show | jobs
by showell 6011 days ago
Other folks have tried to solve the problem of cleanly creating HTML from within Python itself, which I think is what you are alluding to. It's not a goal for me. To the extent that my markup is pretty static, but the content is dynamic, I try to use a templating language beneath SHPAML. If the structure of the page itself needs to be dynamic, then I probably want to serve up JSON to the browser, not HTML, and then let Javascript manipulate the DOM, taking HTML (and SHPAML) mostly or completely out of the equation. I think there are some cases when you want the power of the server-side programming language to help you build documents, but that is often a smell that your documents are overly complex, or that your templating language is weak, or that your UI is too complicated for browsers, or that your client-side code isn't pulling its weight, etc.
1 comments

so, if i understand right, you think it's better to implement it as a separate language to stop people doing things that you don't think they should do, or think they don't need?

apart from stopping people from doing things, are there any what you might call "positive" reasons - advantages - to doing it your way?

If my post made it sound like I am trying to stop people from doing anything, then it just came out wrong. I do think there are legitimate reasons to mostly build documents within a full-featured programming language, and I wouldn't stop people from doing that. I prefer to build the markup itself in a markup language with lightweight syntax, because documents should be readable, and markup languages have syntax specifically tailored for document readability. Then I supply dynamic content via the templating language.