【发布时间】:2012-11-21 08:17:05
【问题描述】:
我有一个使用大量包含文件的页面。它动态选择要使用的正确包含文件。我希望(在包含文件中)能够向 grails 指定我希望它在运行中将特定的 <link rel="stylesheet"/> 标记包含在头部中。
像这样的东西输出..
<html>
<head>
<title>My Life :: My Pets</title>
<link rel="stylesheet" href="style.css" type="text/css"> <!-- Normal Site Style -->
<link rel="stylesheet" href="include-my-pets" type="text/css"> <!-- Dynamic Style for Include -->
</head>
<body>
<h1>My Pets</h1>
<!-- This is the include file start -->
In the GSP here I said something like:
<r:require disposition="head">
<link rel="stylesheet" href="include-my-pets" type="text/css"> <!-- Dynamic Style -->
</r:require>
to get the CSS link tag pushed into the head.
<!-- This is the include file end -->
</body>
</html>
使用<r:script/> 标签对我来说效果很好。我可以在任何包含文件中指定任何位置:
<r:script disposition="head">
alert ('hello')
</r:script>
我的布局会自动将警报 hello 卡在页面头部的 <script/> 标记内。它也会从身体中移除。
【问题讨论】:
标签: css grails layout plugins resources