By Sebastiaan de Jonge, published on Friday, January 18, 2013 at 08:00

Unfortunately, adding Fluid objects to a script block in your Fluid template won't work directly. This snippet will show you how you can still add these objects with a little trick.

<script type="text/javascript">
	<![CDATA[
	$(document).ready(function() {
		$("#foo").click(function() {
			// Do something
			// Do somthing else
			var message = "]]>{f:translate(key:'message.completed', htmlEscape:'false') -> f:format.raw()}<![CDATA[";
			$("#bar").text(message);
		});
	});
	]]>
</script>

How it works

The CDATA prevents Fluid from parsing any data it contains, this will make sure that only the objects will parsed.

Comments