Bug #45071

Fluid tries to parse inside an in-HTML Javascript code

Added by Thiago Colares over 2 years ago. Updated almost 2 years ago.

Status:Closed Start date:2013-02-01
Priority:Won't have this time Due date:
Assigned To:- % Done:

0%

Category:View
Target version:TYPO3 Flow Base Distribution - 1.1.1
Has patch:No Affected Flow version:FLOW3 1.1.0

Description

Example. When I try this:

<script type="text/javascript">
    $(function(){
        var id = '#{id}';
        $(id).datepicker({
            dateFormat: "dd/mm/yy",
            changeMonth: true,
            changeYear: true
        });

    });
</script>

I got this HTML as result:

<script type="text/javascript">
    $(function(){
        var id = '#dummy-id-01';
        $(id).datepicker(Array);
</script>

To overcome this issue, we inserted a dummy comment. :)

<script type="text/javascript">
    $(function(){
        var id = '#{id}';
        $(id).datepicker({
            dateFormat: "dd/mm/yy", // DO NOT EVER REMOVE THIS COMMENT!
            changeMonth: true,
            changeYear: true
        });

    });
</script>

So, The HTML results is as expected:

<script type="text/javascript">
    $(function(){
        var id = '#dummy-id-01';
        $(id).datepicker({
            dateFormat: "dd/mm/yy", // DO NOT EVER REMOVE THIS COMMENT!
            changeMonth: true,
            changeYear: true
        });
</script>


Related issues

duplicates TYPO3.Fluid - Feature #43356: Allow Fluid arrays only in ViewHelper arguments Resolved 2012-11-27
duplicates TYPO3.Fluid - Bug #44140: Unlucky JavaScript syntax can break inline tags Resolved 2012-12-20

History

#1 Updated by Thiago Colares over 2 years ago

NOTE: the FLUID parse a Javascript array, but it should not!!

#2 Updated by Adrian Föder over 2 years ago

  • Status changed from New to Closed
  • Priority changed from Should have to Won't have this time

Thiago, this is as per-design and is "fixed" in version 2.0.
Meanwhile, wrap your JavaScript code in CDATA blocks, like

 1<script type="text/javascript">
 2<![CDATA[
 3    $(function(){
 4        var id = '#]]>{id}<![CDATA[';
 5        $(id).datepicker({
 6            dateFormat: "dd/mm/yy",
 7            changeMonth: true,
 8            changeYear: true
 9        });
10
11    });
12]]></script>

Untested.

Feel free to reopen if necessary.

#3 Updated by Thiago Colares over 2 years ago

Ok! Thanks for clarify me!

Adrian Föder wrote:

Thiago, this is as per-design and is "fixed" in version 2.0.
Meanwhile, wrap your JavaScript code in CDATA blocks, like

[...]

Untested.

Feel free to reopen if necessary.

#4 Updated by Karsten Dambekalns almost 2 years ago

  • Target version changed from 2052 to 1.1.1

Also available in: Atom PDF