将Smarty变量传递到Javascript链接“src”属性 [英] Passing a Smarty variable into Javascript link "src" attribute

查看:94
本文介绍了将Smarty变量传递到Javascript链接“src”属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经分配了一个Smarty变量:

I've assigned a Smarty variable:

{assign var="siteurl" value="http://website.com"}

我可以在我的header.html文件中成功使用它来调用CSS链接:

I can successfully use it in my header.html file to call a CSS link:

<link rel="stylesheet" type="text/css" href="{$siteurl}/style.css" />

显示

<link rel="stylesheet" type="text/css" href="http://website.com/style.css" />

然而,当我对Javascript源代码执行相同操作时,它会打印出{$ siteurl} :

However, when I do the same for a Javascript source, it literally prints out "{$siteurl}":

<script type="text/javascript" src="{$siteurl}/scripts.js"></script>

显示

<script type="text/javascript" src="{$siteurl}/scripts.js"></script>

为什么这个Smarty变量没有按预期显示?

Why isn't this Smarty variable displaying as expected?

推荐答案

解决问题!
如上面的评论所述,我正在开发一个会员系统。我不确定他们是否在他们的初始文件末尾打开了smarty {literal}标签,然后在最后关闭它们,或者什么。但修复正在取代

Problem Solved! As mentioned in the comments above, I am working on an aMember system. I'm not sure if they leave smarty {literal} tags open at the end of their initial files, and then close them at the end, or what. But the fix was replacing

{$siteurl}

{/literal}{$siteurl}{literal}

我尝试将反向{literal}标记放在文档的开头和结尾,但是它引发了错误。我必须为每个javascript src实例手动输入上面的代码。

I tried putting the reverse {literal} tags at the beginning and end of the document, but it threw an error. I have to manually put the code above for each javascript src instance.

非常感谢每个人的帮助!!

这篇关于将Smarty变量传递到Javascript链接“src”属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆