2014-02-17 24 views
2

是否可以在html中引用cf變量? 例子:在html中引用ColdFusion變量

<cfset langValue ="uk"> 

<html lang="#langValue#"> 

這樣是不行的,但是如果我再與CF標籤打印出來,它顯然作品:

<cfoutput> #langValue# </cfoutput> 

任何如何引用langValue變量在html lang標籤?

+0

FWIW,它無關HTML :)如果你想要的變量進行評估,則必須將它包裝用'cfoutput',如下所述。否則,CF會忽略它並返回您按「原樣」輸入的確切文本。磅標誌和所有。 – Leigh

+1

你甚至搜索過如何輸出ColdFusion變量嗎? –

+3

這可能是有用的:http://learncfinaweek.com/ – duncan

回答

9

你一定要確保你的包裹中的HTML cfoutput

<cfoutput> 
    <html lang="#langValue#"> 
</cfoutput> 
0

我不使用任何CFSET更長。 新的辣味是:

<cfscript> 
langValue = 'uk' 
</cfscript> 
<cfoutput> 
<html lang="#langValue#"> 
</html> 
</cfoutput>