我试着搜索,但不知怎的,我无法思考我需要使用健全的代码在html元素中添加动态标签.不确定这是不是好的做法,但想问一下.现在我知道如何将cssclass应用于href中的class属性.但是如果我想在href中注入整个属性"class ='one'"怎么办呢?
可以做到这一点.我知道我可以做点什么
<a href="${properties['jcr:titleurl']}" class="${properties.openinnewwindow ? 'nonunderline' : ''}"> <h3>${properties['jcr:title']}</h3></a>
Run Code Online (Sandbox Code Playgroud)
但我想这样做,
<div class="col-md-12">
<a href="${properties['jcr:titleurl']}" data-sly-test="${properties.openinnewwindow ? 'class=one' : class='two'}"> <h3>${properties['jcr:title']}</h3></a>
Run Code Online (Sandbox Code Playgroud)