This is a migrated thread and some comments may be shown as answers.

ColdFusion Variable Inside a Template

3 Answers 48 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Ashleigh L
Top achievements
Rank 1
Ashleigh L asked on 27 Apr 2015, 02:51 PM

I'm implementing Kendo on a site that uses ColdFusion as our server-side language. I'm setting up a template and I have situation where I must‚Äč use a ColdFusion variable inside the template. For those not familiar w/ ColdFusion, it uses the # to indicate ColdFusion markup - ie. if I wanted the content of a div to be populated from a CF variable, I'd have something like:

<div>#cf_variable#</div>

In fact, the example above is pretty much exactly what I'm trying to do, just inside a template:

<script type="text/x-kendo-template" id="tile_template">
    <div class="padding list-items-footer k-block">
        <button type="button" class="btn btn-success">
            <i class="fa-icon-play"></i> <span class="hidden-xs">##APPLICATION.LC.getValue("LaunchButton")##</span>
        </button>
    </div>
</script>

APPLICATION.LC is our system for multi-lingual text/labels, which is why it's a requirement.

 I initially only had single # on each side of the CF variable, but that gave me a javascript error. Adding the second # to each side (which is how you escape the # in CF), stopped the error, but what's actually being rendered in the button is 'APPLICATION.LC.get value("LaunchButton")', instead of the CF-calculated value. Additionally, trying to escape the hashes using \, as suggested in the template help, (ie.\#APPLICATION.LC.getValue("LaunchButton")\#), also doesn't cause a javascript error, but again, only outputs '#APPLICATION.LC.get value("LaunchButton")#'.

I was able to find this thread (http://www.telerik.com/forums/syntax) where it was suggested that the selector could be changed for the Kendo templating system, but no further information was provided on how.

For ease of updating in the future, I'd prefer if we didn't have to change the selector, but I realize it may be inevitable. Any suggestions/guidance that can be provided would be appreciated.

3 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 29 Apr 2015, 02:50 PM
Hello Shimmoril,

Could you please share the server output from your initial try (with single "#" symbols) as from the provided information it seems that the code is not evaluated on the server side? Also could you please make sure that your are not missing some additional syntax in order the wrapped code is evaluated?

<span class="hidden-xs">#APPLICATION.LC.getValue("LaunchButton")#</span>


Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Accepted
Cristiano
Top achievements
Rank 1
answered on 30 Apr 2015, 07:31 AM

Hello Shimmoril,
there is two possible solutions:

1) if you want render a simply ColdFusion variables, use this syntax
----- premise 1 -----
<cfset a = "click here">
-------------------
<cfoutput>
<span class="hidden-xs">#a#</span>
</cfoutput>

2) if you want render a Kendo variable and the name of variables is on a ColdFusion variables, use this is syntax
----- premise 2 -----
<cfset a = "label_click">
-------------------
<cfoutput>
<span class="hidden-xs">##= #a# ##</span>
</cfoutput>

Best Regards

0
Ashleigh L
Top achievements
Rank 1
answered on 30 Apr 2015, 04:55 PM
Cristiano - wow, I'm such an idiot; I was so focused on the templating stuff I totally forgot about needing cfoutput. Thanks!
Tags
Templates
Asked by
Ashleigh L
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Cristiano
Top achievements
Rank 1
Ashleigh L
Top achievements
Rank 1
Share this question
or