Suggestion #28437
Viewhelper to escape quotes and remove newlines for Javascript
Status: | New | Start date: | 2011-07-24 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | - | % Done: | 0% |
|
Category: | - | |||
Target version: | - | |||
Has patch: | Tags: |
Description
Removes linebreaks and escapes ' (or ").
By default ' is replaced by \', but you can set the argument
quote to say that all " should be replaced by \".
As soon as I'm allowed to I will commit it to the repository.
= Examples =
<script type="text/javascript">
var myString = '<f:jsString>this is a string<br />
perhaps it has a linebreak<br />
or it has a ' and would break the Javascript!</f:jsString>';
</script>
<output>
<script type="text/javascript">
var myString = 'this is a string<br />perhaps it has a linebreak<br />or it has a \' and would break the Javascript!';
</script>
</output>
<script type="text/javascript">
var myString = "<f:jsString quote='\"'>this is a string and the " should be escaped</f:jsString>";
</script>
<output>
<script type="text/javascript">
var myString = "this is a string and the \" should be escaped";
</script>
</output>
History
#1 Updated by Bastian Waidelich about 4 years ago
- Tracker changed from Feature to Suggestion