|texte_script

The |texte_script filter transforms tag output into a character string that can be used in complete security by a PHP or JavaScript script.

  • New in : SPIP 1.4

Applications

The following PHP script provides an example:

<?php $x = '[(#TEXTE|texte_script)]'; ?>

Attention: make sure to use the ’ (simple quote) character and not the " (double quote) character to delimit your PHP variable. In fact, if you used the double quote and your text contained the $ sign, the result could be quite catastrophic (partial display, display of something else, PHP crashing, etc.).

JS in a template (transmit a language string)

<script>
jQuery(function($) {
…
	allDayHtml:'<:organiseur:cal_jour_entier|texte_script:>',
…
</script>

Applied to a tag in an HTML template, unrelated to a JS or PHP script, this filter simply resorts to escaping any apostrophe in the text, e.g. Daniel\'s new car.

Voir aussi

On Programmer.spip.net

Author Mark Published : Updated : 21/07/23

Translations : català, English, Español, français, Nederlands, Português