<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Macro expand/evaluate a string like in 3.x</title><link>https://answers.axonivy.com/questions/474/macro-expand-evaluate-a-string-like-in-3-x</link><description>&lt;p&gt;I have a text content object which contains Ivy macros like &lt;code&gt;&amp;lt;%= in.abc.var%&amp;gt;&lt;/code&gt;. This content object is used as content in an email element with &lt;code&gt;&amp;lt;%ivy.cms.co("...")%&amp;gt;&lt;/code&gt;. This works very good.&lt;/p&gt;
&lt;p&gt;Now we want to do the same but call it with an external function which gets the subject and the content as an argument. But this leads to the following exception: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ch.ivyteam.ivy.macro.MacroException: Error during macro expansion: IvyScript Runtime Exception in Instruction: in.abc.var&amp;lt;br/&amp;gt;
    Block: in.abc.var&amp;lt;br/&amp;gt;
    at  ch.ivyteam.ivy.macro.internal.MacroExpander.expandMacros(MacroExpander.java:84)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is there a possibility to evaluate a string that contains ivy macros like it was possible in Ivy 3.x?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/474/macro-expand-evaluate-a-string-like-in-3-x" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 27 Jun 2013 10:44:36 -0400</lastBuildDate><item><title>Answer by Bruno Bütler</title><link>https://answers.axonivy.com/questions/474/macro-expand-evaluate-a-string-like-in-3-x/475</link><description>&lt;p&gt;In Ivy 4+ you can use placeholders like {0} and {1} in your content objects. In &lt;code&gt;ivy.cms.co()&lt;/code&gt; you then can pass a list of parameters that will replace the placeholders.  &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/MyContentObject = "My name is {0} and I am {1} years old."
ivy.cms.co("/MyContentObject", ["Michael", in.age])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Unfortunately we do not support the dedicated functions &lt;code&gt;expand()&lt;/code&gt; and &lt;code&gt;evaluate()&lt;/code&gt; like in 3.x . &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Bruno Bütler</dc:creator><pubDate>Thu, 27 Jun 2013 10:44:36 -0400</pubDate><guid>https://answers.axonivy.com/questions/474/macro-expand-evaluate-a-string-like-in-3-x/475</guid></item></channel></rss>