简体   繁体   中英

Blogspot Template: pass widget output to javascript

I want to replace YOUR_LABEL_HERE with widget output value "< data:content/ >" simply i want to pass widget output to my javascript

This is my code:

  <b:section class='section' id='my-html-sec-test'>
        <b:widget id='HTML555' locked='true' title='MY LABEL' type='HTML' version='1'>
          <b:widget-settings>
            <b:widget-setting name='content'>  Label  </b:widget-setting>
          </b:widget-settings>
          <b:includable id='main'>
      <!-- only display title if it's non-empty -->
      <b:if cond='data:title != &quot;&quot;'>
      </b:if>
      <div class='widget-content'>
        <data:content/>

            <script src="/feeds/posts/default/-/YOUR_LABEL_HERE?published&amp;alt=json-in-script&amp;callback=labelthumbs" type='text/javascript'> </script>

    </div>

      <b:include name='quickedit'/>
    </b:includable>
        </b:widget>
      </b:section>

You need to use Blogger expr before src in order to pass widget data content as a string

<b:section class='section' id='my-html-sec-test'>
  <b:widget id='HTML555' locked='true' title='MY LABEL' type='HTML' version='1'>
    <b:widget-settings>
      <b:widget-setting name='content'>  Label  </b:widget-setting>
    </b:widget-settings>
    <b:includable id='main'>
      <!-- only display title if it's non-empty -->
      <b:if cond='data:title != &quot;&quot;'>
      </b:if>
      <div class='widget-content'>
        <script expr:src='"/feeds/posts/default/-/" + data:content + "?published&amp;alt=json-in-script&amp;callback=labelthumbs"' type='text/javascript'></script>
      </div>

      <b:include name='quickedit'/>
    </b:includable>
  </b:widget>
</b:section>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM