Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to send html tags in twig template

//To send html tags in twig template ( 1 )
{{ '<div id="div">Hi</div>'|raw }}

//outputs => Hi ( Interpreted as HTML code )

/*If we don't use the raw function wich is the dafault in twig 
( Due to security to pervent injecting some malicious js code .. )
( 2 )
*/
{{ '<script>Js code</script>'}}

// outputs => <script>Js code</script> ( Written as text )
/* It's not recommended to use this function because it's not safe but
there are some cases when we need it just like the first example
*/
 
PREVIOUS NEXT
Tagged: #send #html #tags #twig #template
ADD COMMENT
Topic
Name
2+2 =