hamlet and #

54 views
Skip to first unread message

Bulat Ziganshin

unread,
Jun 13, 2012, 12:46:38 PM6/13/12
to yeso...@googlegroups.com
Hello yesodweb,

i'd rather easily converted my html files to hamlet format. the most
problematic thing both for conversion and probably further
maintenance was the handling of multiline contols - i mean than
something like

<p>text
text</p>

should be converted to

<p>text #
text

probably it was very motivated decision, but afair most html
templating systems i've learned don't require #'s, and for conversion
of typical, already structured html file it's the most time-consuming
and bug-prone part - the rest is just to remove all those </...> tags
and it's very fast and easy

so, the question is obvious - may be this decision need to be reversed?


--
Best regards,
Bulat mailto:Bulat.Z...@gmail.com

Greg Weber

unread,
Jun 13, 2012, 2:00:19 PM6/13/12
to yeso...@googlegroups.com
I don't think the current haskell hamlet implementation has the most
natural defaults, but it is easy to explain what the rules are.
For my other implementations [1] it defaults to adding new lines or a
space and I rarely need to point out spacing to hamlet.

[1] https://github.com/gregwebs/hamlet.rb

Michael Snoyman

unread,
Jun 14, 2012, 12:11:13 AM6/14/12
to yeso...@googlegroups.com
There are two things I was trying to avoid in designing the current setup:

* A bunch of special case rules about when to add whitespace. I like
the fact that we can explain things with one sentence: there's no
extra whitespace added.
* It's possible to express anything. If whitespace is *always* added,
it's impossible to use Hamlet tag syntax for, e.g. <i>Michael</i>'s
car.

But we can probably still hit both of those requirements if we (1)
switch the default to *always* adding whitespace after a tag and (2)
having some escape mechanism (e.g., a backslash at the end of the
line) to disable auto-whitespace.

Personally, I don't mind the current setup, but if people want to make
the change, I'm open to it. What's general consensus?

Felipe Almeida Lessa

unread,
Jun 14, 2012, 6:42:41 AM6/14/12
to yeso...@googlegroups.com

I'd prefer using backslashes, but it would be a PITA to upgrade all templates by hand. Perhaps it would be sufficient to have a "transition knob" which printed a warning every time Hamlet assumed a space where it previously wouldn't (assuming that a tool to automagically upgrade would be too expensive to build).

--
Felipe – enviado do meu Galaxy Tab.

Bulat Ziganshin

unread,
Jun 14, 2012, 8:13:10 AM6/14/12
to Greg Weber
Hello Greg,

Wednesday, June 13, 2012, 10:00:19 PM, you wrote:

> [1] https://github.com/gregwebs/hamlet.rb

btw, you forgot to close the last ``` html tag in README.rd:

``` html
<b>no space</b>none after bold. Two spaces after a period is bad!

## I18n support

You can hook up i18n support the same way you would for other templating lanugages.
[https://github.com/grosser/gettext_i18n_rails](This rails plugin) works out of the box.

Bulat Ziganshin

unread,
Jun 14, 2012, 8:23:05 AM6/14/12
to Greg Weber
Hello Greg,

Wednesday, June 13, 2012, 10:00:19 PM, you wrote:

> [1] https://github.com/gregwebs/hamlet.rb

also this line has 2 broken links plus word "langauge"

You can see the [original hamlet templating langauge](http://www.yesodweb.com/book/templates) and the
[javascript port](hamlet: https://github.com/gregwebs/hamlet.js).

Bulat Ziganshin

unread,
Jun 14, 2012, 4:36:19 PM6/14/12
to Michael Snoyman, yeso...@googlegroups.com
Hello Michael,

Thursday, June 14, 2012, 8:11:13 AM, you wrote:

> There are two things I was trying to avoid in designing the current setup:

IMVHO, these rules looks like the good fit for quick&dirty proof-of-concept
implementation, but for long-running "production-grade" framework it has
the following disadvantages (repeating and extending myself):

- it's unexpected. at least, plain English, html and most templating
systems are doing opposite
- it makes (much?) harder to convert manually from html to hamlet.
automatic html2hamlet conversion tool generates unreadable hamlet
files, so i prefer to convert by hand. although now i think that it may
be solved by making smarter conversion tool
- it makes it harder to further maintain hamlet templates

so, i believe that it's the problem that's better to be solved earlier than
later, when hamlet will have larger userbase

> * A bunch of special case rules about when to add whitespace. I like
> the fact that we can explain things with one sentence: there's no
> extra whitespace added.

i think that the best thing is to copy existing rules either from html
or popular indent-based templating systems. whitespacing rules isn't
the field where users demand more diversity

> * It's possible to express anything. If whitespace is *always* added,
> it's impossible to use Hamlet tag syntax for, e.g. <i>Michael</i>'s
> car.

even without any special whitespacing rule, one can just explicitly close
the tag and continue text on the same line waiting till the next space
Reply all
Reply to author
Forward
0 new messages