How to display variable value in Head HTML code web part?

Mani SJ asked on May 20, 2020 06:53

I have below code in head html code webpart

{% var image=""; if(condition){image="X";}else{image="Y";} %}

{% if(image != null) <meta content={% kenticofunction(image) %} > %}

Above meta tag is not displayed in html output. Not sure whether macros I wrote is in correct format or something fails

Recent Answers


Juraj Ondrus answered on May 20, 2020 07:21

I would recommend using the macro debug to see what are the resolved values and also check Event log for any errors.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on May 20, 2020 13:11

you are doing macro inside macro, but incorectly.. kenticofunction must be a macro method. Try this:

{% var image=""; if(condition){image="X";}else{image="Y";} %}

{% if(image != null) ("<meta content="+ MacroMethod(image)+ ">")%}

0 votesVote for this answer Mark as a Correct answer

Mani SJ answered on May 21, 2020 01:31

Peter, That does not work. I see below error in event log

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Anyhow I resolved using Custom Macro Method

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.