我正在尝试在 data-sly-template 调用中调用引号内的变量。我希望输出包含我的字符串和引号内的适当变量。下面是模板和我用来调用它的字符串:
模板:
<!-- template -->
<template data-sly-template.bnrButton="${ @ style='String: button color class (default btn-primary)', classes='String: additional component button classes', text='String: button text (translation key)', defaultText='String: default button text (translation key)', link='String: link target for button (# is default)', fullWidth='Boolean: whether to display button in full width of container', noFollow='Boolean: if button should have a nofollow tag (no is def)', gaCategory='String: GA Category', gaEvent='String: GA Event', gaLabel='String: GA Label', gaAction='String: GA Action'}">
<a class="btn ${style || 'btn-primary'} hidden-print ${classes}${fullWidth ? ' btn-full-width' : ''}" role="button" href="${link || '#'}" rel="${noFollow ? 'nofollow' : ''}" onclick="${gaEvent @ context = 'scriptString'}">${text || defaultText @ i18n}</a>
</template>
<!-- call made to the template -->
<sly data-sly-call="${patterns.bnrButton @ style='btn-secondary-light', classes='btn-sm', text=teaser.libraryButtonHeading, defaultText='View Library', link=teaser.myLibraryLink.href, fullWidth='true', newWindow='false', gaEvent='trackEvent('Test 1','Test 2','${teaser.teaserMessage}')'}"></sly>
如果尝试了多种组合以获取 teaser.teaserMessage 以打印创作的消息,但由于模式调用已经在引号内而出现问题。我希望能够将单个字符串(在模板调用中调用)传递给包含 onclick 所需的所有信息的模板。
想法?
谢谢你。