<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Setting a variable in HubL in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Setting-a-variable-in-HubL/m-p/9324#M945</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I am not sure if this is by design or a bug in your implementation but it certainly does not seem to be consistent. I have narrowed it down. The below snippet works as expected:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;{% set queryparam2 = "initial" %} &lt;BR /&gt;{% if 1 == 1 %} &lt;BR /&gt;   {% set queryparam2 = queryparam2 ~ "&amp;amp;type=111" %} &lt;BR /&gt;{% endif %} &lt;BR /&gt;{{queryparam2}}&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Above prints "initial&amp;amp;type=111" as expected, meaning one can change a variable's value inside an if block. However, introducing a for loop: &lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;{% set queryparam2 = "initial" %} 
{% if 1 == 1 %} 
  {% set queryparam2 = queryparam2 ~ "&amp;amp;type=111" %} 
  {% for part in [1] %}
     {% set queryparam2 = queryparam2 ~ "&amp;amp;type=222" %} 
  {% endfor %} 
{% endif %} 

{{queryparam2}}&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Above prints "initial&amp;amp;type=111" which is NOT as expected, it should be "initial&amp;amp;type=111&amp;amp;type=222", meaning one can NOT change a variable's value inside a for block and access it outside that block, even with the variable defined outside the scope of the for block. Comments?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Mar 2017 21:30:59 GMT</pubDate>
    <dc:creator>wnell</dc:creator>
    <dc:date>2017-03-13T21:30:59Z</dc:date>
    <item>
      <title>Setting a variable in HubL</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Setting-a-variable-in-HubL/m-p/9324#M945</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am not sure if this is by design or a bug in your implementation but it certainly does not seem to be consistent. I have narrowed it down. The below snippet works as expected:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;{% set queryparam2 = "initial" %} &lt;BR /&gt;{% if 1 == 1 %} &lt;BR /&gt;   {% set queryparam2 = queryparam2 ~ "&amp;amp;type=111" %} &lt;BR /&gt;{% endif %} &lt;BR /&gt;{{queryparam2}}&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Above prints "initial&amp;amp;type=111" as expected, meaning one can change a variable's value inside an if block. However, introducing a for loop: &lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;{% set queryparam2 = "initial" %} 
{% if 1 == 1 %} 
  {% set queryparam2 = queryparam2 ~ "&amp;amp;type=111" %} 
  {% for part in [1] %}
     {% set queryparam2 = queryparam2 ~ "&amp;amp;type=222" %} 
  {% endfor %} 
{% endif %} 

{{queryparam2}}&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Above prints "initial&amp;amp;type=111" which is NOT as expected, it should be "initial&amp;amp;type=111&amp;amp;type=222", meaning one can NOT change a variable's value inside a for block and access it outside that block, even with the variable defined outside the scope of the for block. Comments?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 21:30:59 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Setting-a-variable-in-HubL/m-p/9324#M945</guid>
      <dc:creator>wnell</dc:creator>
      <dc:date>2017-03-13T21:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a variable in HubL</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Setting-a-variable-in-HubL/m-p/9399#M948</link>
      <description>&lt;P&gt;It's a known limitation. Variables within a for loop are only accessible within the for loop.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 16:34:50 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Setting-a-variable-in-HubL/m-p/9399#M948</guid>
      <dc:creator>ndwilliams3</dc:creator>
      <dc:date>2017-03-14T16:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a variable in HubL</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Setting-a-variable-in-HubL/m-p/9400#M949</link>
      <description>&lt;P&gt;Can you explain what you are trying to do? Maybe there is a workaround.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 16:37:15 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Setting-a-variable-in-HubL/m-p/9400#M949</guid>
      <dc:creator>ndwilliams3</dc:creator>
      <dc:date>2017-03-14T16:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a variable in HubL</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Setting-a-variable-in-HubL/m-p/9403#M950</link>
      <description>&lt;P&gt;Thanks for the info. &amp;nbsp;That is what I thought.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did implement a workaround but it does make life a bit harder.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 17:20:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Setting-a-variable-in-HubL/m-p/9403#M950</guid>
      <dc:creator>wnell</dc:creator>
      <dc:date>2017-03-14T17:20:35Z</dc:date>
    </item>
  </channel>
</rss>

