Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outputfilter.trimwhitespace.php strips KnockoutJS comments #82

Closed
vanderlee opened this issue Aug 19, 2015 · 4 comments
Closed

outputfilter.trimwhitespace.php strips KnockoutJS comments #82

vanderlee opened this issue Aug 19, 2015 · 4 comments

Comments

@vanderlee
Copy link

KnockoutJS has a syntax for MVVM that uses HTML comments in the form of <!-- ko ... -->...</!-- /ko -->.

The outputfilter.trimwhitespace.php output filter strips out all comments (except the MSIE-specific ones). As far as I know, there is no workaround or fix except stripping out the line that removes the comments from the Smarty code; obviously not a good solution.

Is it possible to add a way to keep these (or other framework's) comments?

See this old stackoverflow for more details: http://stackoverflow.com/questions/15009881/smarty-comment-stripping-and-knockoutjs

@mohrt
Copy link
Contributor

mohrt commented Aug 27, 2015

outputfilter.trimwhitespace.php is not loaded by default, you must explicitly load it. Just don't load the filter if you don't want it applied?

@vanderlee
Copy link
Author

You are correct, but then it's still an all-or-nothing deal.
Either you get no trimming at all or you get whitespace trimming AND comment trimming.

It would be nice if they were either separated (which I guess would be a performance drain) or configurable.

@mohrt
Copy link
Contributor

mohrt commented Aug 27, 2015

You can make them separate yourself with custom output filters. Copy the filter and make your own rules. Another approach, make a prefilter to replace the comment tags you want to keep with a placeholder, then swap them back with an output filter after the trimming is complete (load your filter after the trimwhitespace filter.)

@uwetews
Copy link
Contributor

uwetews commented Feb 11, 2016

The change is committed now

@uwetews uwetews closed this as completed Feb 11, 2016
think-mcunanan pushed a commit to think-mcunanan/smarty that referenced this issue Mar 22, 2023
Merge release-2.0.8 into master branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants