Bug #45071

Fluid tries to parse inside an in-HTML Javascript code

Added by Thiago Colares over 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Won't have this time
Assignee:
-
Category:
View
Start date:
2013-02-01
Due date:
% Done:

0%

Estimated time:
Has patch:
No

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

Is duplicate of TYPO3.Fluid - Feature #43356: Allow Fluid arrays only in ViewHelper argumentsResolvedSebastian Kurfuerst2012-11-27

Actions
Is duplicate of TYPO3.Fluid - Bug #44140: Unlucky JavaScript syntax can break inline tagsResolved2012-12-20

Actions
#1

Updated by Thiago Colares over 8 years ago

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

#2

Updated by Adrian Föder over 8 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

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

    });
]]></script>

Untested.

Feel free to reopen if necessary.

#3

Updated by Thiago Colares over 8 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 about 8 years ago

  • Target version changed from 2052 to 1.1.1

Also available in: Atom PDF