vapor / leaf-kit

🍃 An expressive, performant, and extensible templating language built for Swift.
https://docs.vapor.codes/4.0/leaf/getting-started
MIT License
47 stars 38 forks source link

Allow escaped quotes in tag parameters #124

Closed roya1v closed 4 months ago

roya1v commented 1 year ago

These changes are now available in 1.10.6

Allows escaped quotes in tag parameters so you can do something like #myCustomTag("this \"thing\" is cool")

Solves #122

0xTim commented 1 year ago

@roya1v why not use \" for an escaped quote?

roya1v commented 1 year ago

@0xTim that was my initial idea. As far as I tried we don't distinguish between escaped and not-escaped quotes. I tried to dig deeper but couldn't find a place in leaf-kit to amend this behaviour. Correct me please if I'm wrong

Screenshot 2023-05-22 at 12 12 45 Screenshot 2023-05-22 at 12 13 02

Now that I think about it, two slashes might work, lmk if you would prefer that

Screenshot 2023-05-22 at 19 34 22
0xTim commented 1 year ago

Ah I see, I think the issue you're having is that Swift will automatically count the \, whereas if it was created in a template directly \" should work fine so I think \\ works in this case

roya1v commented 1 year ago

Hey @0xTim sorry I don't know if you didn't see it or didn't have time to take a look. I've pushed the change to \\

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 81.51%. Comparing base (f6a08a1) to head (0d51e90).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #124 +/- ## ========================================== - Coverage 82.09% 81.51% -0.59% ========================================== Files 25 25 Lines 2603 2510 -93 ========================================== - Hits 2137 2046 -91 + Misses 466 464 -2 ``` | [Files](https://app.codecov.io/gh/vapor/leaf-kit/pull/124?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor) | Coverage Δ | | |---|---|---| | [Sources/LeafKit/LeafLexer/LeafLexer.swift](https://app.codecov.io/gh/vapor/leaf-kit/pull/124?src=pr&el=tree&filepath=Sources%2FLeafKit%2FLeafLexer%2FLeafLexer.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9MZWFmS2l0L0xlYWZMZXhlci9MZWFmTGV4ZXIuc3dpZnQ=) | `97.76% <100.00%> (-0.08%)` | :arrow_down: | ... and [16 files with indirect coverage changes](https://app.codecov.io/gh/vapor/leaf-kit/pull/124/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor)