yesodweb / shakespeare

Haml-like template files that are compile-time checked
http://www.yesodweb.com/book/shakespearean-templates
MIT License
136 stars 76 forks source link

Hamlet chokes at '\r' inside interpolation on Windows. #192

Open arrowd opened 8 years ago

arrowd commented 8 years ago

The code

let a = [shamlet|#{f a
                            b c}|]

yields unexpected '\r', expecting " " or "}" on Windows. Changing source line endings doesn't help, because template code is still \r\n-ended.

snoyberg commented 8 years ago

This happens on non-Windows too, newlines are not supported inside an interpolation.

janvogt commented 5 years ago

@snoyberg If newlines are not supported in interpolations, is there any other way to handle long interpolations? I have a function that should be supplied with multiple file paths. I want the designer to select CSS imports from within the template, without any changes to Haskell code. The functionality is already there so

<link href=#{includeCss [ "static/fonts/fonts.scss", "static/css/bootstrap-2.7.5.min.css", "static/font-awesom-1.2.3.css"]} rel="stylesheet" type="text/css">

works fine but is terrible on small screens. So what I want to do is sth. like this:

<link href=#{includeCss [ "static/fonts/fonts.scss"
                        , "static/css/bootstrap-2.7.5.min.css"
                        , "static/font-awesom-1.2.3.css"
                        ]} rel="stylesheet" type="text/css">

I did not open a new issue, because I think this is just another example for the OP's problem, but am happy to do so, if you disagree.

snoyberg commented 5 years ago

In theory you could use a with in the Hamlet code to define a variable, or define the variable names in the Haskell code.

janvogt commented 5 years ago

@snoyberg Ok, thank you very much. I didn't think of that option. This trades the line-width problem for a nesting one. So I'll keep this as an option in mind, despite living with the oversized lines in the current case. Maybe this could be seen as a rather low-priority feature request for multi-line variable interpolations. Nevertheless thanks to all contributors for creating this marvel of a templating engine :)