Remove erb_parser
and add deface
for transforming HTML+ERB
#60
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request removes the
erb_parser
dependency and addsdeface
for turning HTML+ERB into HTML with<erb>
tags.Here's a summary of what changed:
erb_parser
used to transform the input from<div><%= method %></div>
to<div><erb loud> method </erb></div>
inPhlexing::ErbTransformer
. This was replaced with theDeface::Parser
erb_parser
used to extract the Ruby code from ERB templates inPhlexing::RubyAnalyzer
. This was replaces with ourPhlexing::Parser
class.most
html
variables were renamed tosource
a bunch of new tests for, mostly notably for
Phlexing::Minifier
,Phlexing::Parser
andPhlexing::ErbTransformer
The most important reason for switching from
erb_parser
todeface
is the way howdeface
transforms the HTML+ERB source into HTML.Example
Input:
erb_parser
transform output:Which parsed in Nokogiri ends up with this invalid HTML, because
<erb>
tags (or any tags for that matter) aren't allowed in attributes:deface
transform output:Deface handles this by prefxing the attribute name with
data-erb-
and escapes the value. With that we are able to detect which HTML attributes not to be interpolated, so we can process the value of the attribute manually:Parsing this with Nokogiri gives us the thing we are looking for:
TL;DR:
This allows us to solve issues like #48.