TYPO3 Flow Base DistributionPackagesApplications

Suggestion #28437

Viewhelper to escape quotes and remove newlines for Javascript

Added by Marco Huber about 4 years ago. Updated about 4 years ago.

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>

JsStringViewHelper.zip (5.5 kB) Marco Huber, 2011-07-24 23:31

History

#1 Updated by Bastian Waidelich about 4 years ago

  • Tracker changed from Feature to Suggestion

Also available in: Atom PDF