Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upTagged template literals #58
Conversation
|
Looks like tests prior to 2.3 are failing…is supporting those versions still a requirement? (Ruby 2.5 is now the oldest officially supported version to the best of my knowledge.) |
|
One issue I found: escaping backticks in a JS template literal requires doing |
|
OK, that should be fixed now. |
|
Feel free to drop versions of Ruby prior to 2.3. |
|
Consider updating the README? |
|
Sure, yeah I didn't want to get into docs too much until the approach seemed good to you. Will work on that shortly. |
|
All right, I added docs to the readme and tests are passing now. Looks good to merge? |
|
LGTM.
|
fd146af
into
rubys:master
|
Now moot, but worth noting that without es2015
|
Yep, good call to add that minimum es2015 requirement for the filter. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

This is a first pass at a filter which allows a list of tags for prefixing template literal strings. It will convert this:
to this:
It works with any length of string as well as heredocs. I also provided a customization option for the filter…by default it looks for
htmlandcssbut you can change it to look for any tags you want using thetemplate_literal_tagsoption.I also made sure it doesn't process anything if there's a target for the send, aka
self.htmlorsome_obj.htmlor whatever. Should work around most edge cases.Probably should be a separate PR, but I also fixed a few bugs with the camelCase filter. When using an underscore prefix, before it would turn
_method_nameintoMethodNamerather than_methodName. I also made it support numbers (foo_bar_123becomesfooBar123) and method calls using suffixes like=,?, and!.Let me know what you think!