Open tensiondriven opened 2 years ago
@cmcaine @tensiondriven apologizes for being absent, some unfortunate events took me away from open source for awhile but I'm getting back into the swing of things. I'd love to move forward with this PR, how can I help?
This PR adds support to the
slime
package for HEEx. The main changes to the slim/slime grammar are:When rendering HEEx, attribute values will be escapes with
{ }
instead of#{ }
.When rendering HEEx, tag names prefixed with a colon (
:
) will be rendered with a dot (.
).The dot and curlybrace syntax changes are specific to HEEx.
This is accomplished by adding a
precompile_heex
function, similar to the existingprecompile
function. It works by passing in a set of delimiters for escaping attribute values:These delimiters are passed down into
Slime.Compiler
to allow it to return the proper data structures, depending on if HTML or HEEx is requested. Additionally,Slime.Parser.Nodes.HEExNode
was added which is returned inSlime.Parser.Transform
.The PEG grammar was updated to add the case where a tag name is prefixed with a colon (
:
). When precompile (which targets EEx, not HEEx) is called with input that contains a colon, aSlime.TemplateSyntaxError
is raised.Tests were added in
test/rendering/heex_test.exs
. Testing the HEEx functionality end-to-end was difficult because it would add a dependency onphoenix_slime
, so those tests were omitted. This was picked up in my fork ofphoenix_slime
here: https://github.com/tensiondriven/phoenix_slime/blob/master/test/phoenix_slime_heex_test.exsI also set up a test Phoenix app which pulls in the new versions of Slime and PhoenixSlime here: https://github.com/tensiondriven/phoenix_slime_test
I expect there are still some issues hiding in here somewhere, so please don't merge until enough review has been done. For now, I'm submitting the PR to get the review process going. The test app (linked above) is working and contains as many cases as I could think to test, but I'm sure there are more that are lurking.
Co-Authored-By: Topher Hunt hunt.topher@gmail.com