Live data from Hacker News

Beautiful mini language for outputing HTML in Python

shpaml.webfactional.com

51–60 of 74 posts

Re: Beautiful mini language for outputing HTML in Python

#51
post #37

Earlier quoted context omitted.

When you run SHPAML through the preprocessor, it produces HTML that you can share with other people. So it's not that big an issue. Your greater point is well taken, though--using SHPAML is particularly suited to small teams.

Things can get messy if people sending you patches for something generated, rather than patches for the original source, though. Most such transformations aren't trivially reversible.

I understand the use case, and if people are frequently sending you patches for your HTML, you probably want to make HTML the authoritative source. Do people frequently send you patches for HTML that you author? SHPAML does not allow you to trivially reverse HTML patches, but it does allow you to manually apply them without too much pain, as it lets most HTML pass through unmolested. I actually source control my HTML output to be able to see diffs on the HTML, for what it's worth.

Re: Beautiful mini language for outputing HTML in Python

#52
post #14

Why are most comments here negative? HAML already shown this technology does have value to a significant amount of people. Someone took the time to write this, seems to have done a pretty nice job and is releasing it for anyone to use. I can't see why anyone would feel the need to put it down in the comments. If you don't like, just don't use it.

Because; 1) by posting link to it on discussion site you are assumed to be soliciting opinions. 2) it was called "beautiful". A claim so false as to require immediate and forceful contradiction.

I did not post the link here, nor did I call anything "beautiful," but I presume that the reason the original poster posted the link on a "discussion" site was to solicit "discussion." Immediate and forceful contradiction does not equate to discussion, even when the claim is "so false" as this one.

Re: Beautiful mini language for outputing HTML in Python

#54

this could almost be embedded, which would be much cooler i think. you'd have to define objects with names from html tokens and do some ugly hacking with python's operators. you'd also have to add something other than space between strings (a "+" might be ok). but once you've done that, this could be very neat. no processors - just constructing html in python. (i don't know if this sounds crazy or not, but you can se…

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.

Re: Beautiful mini language for outputing HTML in Python

#55

I'm disappointed they resorted to a one-way preprocessor. Is it really not feasible to make a first-class domain-specific language like this in Python?

The reason I made SHPAML a one-way preprocessor is that my use cases haven't yet given me a compelling reason to write a round tripper, and preprocessing is simple to automate.

I do not know what your criteria are for judging a "first-class" DSL in Python, so I cannot comment on the feasibility. My goal was to create a simple markup language that maps well to HTML and plays nice with templates. SHPAML does that.

Re: Beautiful mini language for outputing HTML in Python

#57
post #32
post #18

Earlier quoted context omitted.

I like what I see of the DSL, but I don't believe meritorious beauty is a matter of taste. Coke vs. Pepsi - taste Python vs. PHP - not-taste For a better explanation, see: http://www.paulgraham.com/taste.html

I think we're in agreement. My distinction is: Beautiful vs Nice - taste. Beautiful vs Ugly - not taste. So, since it's obvious this DSL isn't ugly, being less than beautiful doesn't really merit HN's negative response. In any case, the negative comments seem to be doing great, which is sad for HN. My experience is that people who actually produce stuff (in any field) aren't usually publicly critical of other people'…

Criticism is not a bad thing.

Re: Beautiful mini language for outputing HTML in Python

#58

I no longer fall for languages that only change the syntax for something the author thinks it's cuter...

Right. I don't see any use case for this syntax especially that modern IDEs offer auto completion .

Modern IDEs inject close tags and angle brackets into the source document. The SHPAML preprocessor injects that syntax into the target document. The use case applies to the person who wants clean syntax in the source document and executable syntax in the target document.

Re: Beautiful mini language for outputing HTML in Python

#59

I no longer fall for languages that only change the syntax for something the author thinks it's cuter...

What are your thoughts on HAML and SASS? They aren't simply "cuter" they are a full-blown templating and stylesheet meta language. I've been using SASS in a Python project and love it. The more I use SASS, the more envious I grow of people who get to use HAML.

I was intending on eventually writing my own HAML-type language in Python, but it looks like with SHPAML, I won't have to. Because SHPAML supports raw HTML and doesn't do anything with the {} characters, I can use SHPAML in conjunction with my existing Jinja2 templates. This will enable me to convert my templates organically. The intermediate HTML/Jinja representation doesn't need to appear on disk, so this really looks like an easy way to add "cute" HTML syntax to and existing Python text templating language.

Re: Beautiful mini language for outputing HTML in Python

#60

Earlier quoted context omitted.

i use Markdown ( http://daringfireball.net/projects/markdown/ ) regularly rather than directly writing HTML. like this thing, it's also just syntactic sugar, but it's well-designed and makes it so that i can concentrate on writing and not on formatting syntax. my raw text files are much more source-control friendly, since the diffs are clean.

Markdown is different, though. Rather than trying to cram HTML into a yet another pseudo-programming syntax, it tries to generate HTML that matches common plaintext-formatting conventions. You might not guess Markdown-formatted text was written with a formal markup language in mind. FWIW, there's a C implementation of Markdown called "discount" ( http://www.pell.portland.or.us/~orc/Code/discount/ ) which is crazy fas…

First of all, sorry about the name.

SHPAML is not a pseudo-programming syntax. It is purely a markup language, so there are no programming constructs.

SHPAML very deliberately tries to be a lightweight abstraction on top of HTML, unlike wikis and Markdown, which operate at a higher level abstraction. I am a huge fan of wikis, so I value the higher level abstraction at times, but I also see the need for an in-between solution.

I have not used Markdown much, but I see its merits as well.

Post reply on HN