Latest news, food, business, travel, sport, Tips and Tricks...

Blogger b:include and b:includable Tag

The <b:include> is statement takes all the text/code/markup that exists in the <b:includable> tags and copies it into the part that calling the include statement.

Blogger Inclusion tag Syntax and Attribute

<B:INCLUDE/>

<b:include cond='EXPRESSION'

           data='DATA-ALIAS'

           name='STRING1'/>

<B:INCLUDABLE>

<b:includable id='STRING1'

              var='STRING'>

   <!-- span Block -->

</b:includable>

  • The tags <b:includable> can only nest in a tag <b:widget> or <b:defaultmarkup>.
  • Tags <b:include/> is statement to calling or to include or to take <b:includable> together, and its singleton.
  • 'DATA-ALIAS' is dataset forwarded to be processed inside tag <b:includable>.
  • Attribute name in <b:include> tag, is a statement that he calls <b:includable> to include content together which id same as name.
  • var in <b:includable> tag its data: name to be used by child <data:.../> as children.

<b:include/> and <b:includable> Example

THE INCLUDABLE

<b:includable id='list'>

        <b:loop values='data:foo' var='item'>

        <li>

            <data:item/>

        </li>

        </b:loop>

</b:includable>

CALLING INCLUDABLE 'LIST' WITH DATA-ALIAS

<ol>

<b:include data='{ foo: ["Qux","Quux"] }' name='list'/>

<b:include data='{ foo: ["Corge","Graul"] }' name='list'/>

<b:include data='{ foo: ["Garply","Waldo"] }' name='list'/>

</ol>

RESULT

    1. Qux

    2. Quux

    3. Corge

    4. Graul

    5. Garply

    6. Waldo

With data-alias we can process multiple data with same format and get same result to avoid repeating typing same code again. The data with foo will be forwarded to <b:includable> tag and processed in <b:loop> tag with variable name item transform into <data:item/>.

THE INCLUDABLE WITH CHILD

<b:includable id='list' var='parent'>

    <b:include data='parent' name='list2'/>

</b:includable>

<b:includable id='list2'>

<b:if cond='data:foo'>

        <b:loop values='data:foo' var='item'>

        <li>

            <data:item/>

        </li>

        </b:loop>

<b:elseif cond='data:bar'/>

        <ol>

        <b:loop values='data:bar' var='item'>

            <li><data:item/></li>

        </b:loop>

        </ol>

</b:if>

</b:includable>

CALLING INCLUDABLE 'LIST' WITH DIFFERENT DATA NAME

<ol>

<b:include data='{ foo: ["Qux","Quux"] }' name='list'/>

<b:include data='{ bar: ["Corge","Graul"] }' name='list'/>

<b:include data='{ foo: ["Garply","Waldo"] }' name='list'/>

</ol>

RESULT

    1. Qux

    2. Quux

        1. Corge

        2. Graul

    3. Garply

    4. Waldo

In this example, data with different name and various string forwarded to <b:includable> with a name 'list' and variable 'parent', transform into group data:parent and gave to next <b:includable> with the name 'list2'. Conditional Statement is there to test which group and process with matching statement.

Server Managed Inclusion

Blogger has default inclusion that we can call to be used in our template. This are inclusions that are stored on the Blogger serverside. Mostly marked with prefix super in the inclusion. Other are The Common Inclusion, this inclusion can be installed anywhere except b:skin. The known inclusion present inside default tempate are:

<b:include name='all-head-content'/>

<b:include name='postMetadataJSON'/>

Other Tag

 

,
//