Blogger Script
📅 — 👀 1665 — 👦The following article will detail the blogger's variables, functions, and language.
<b:loop values='data:posts filter (p => p.id != 0)' var='post'>
<h1>Post found: <data:post.title/></h1>
</b:loop>
Javascript was never meant to be the first choice to change DOM on load, instead Blogger layout data tags helps us to make the template with native codes, so that the response time gets better and lesser Javascript is used. Previously added expression were indeed useful ones and the new expressions are much more powerful.
Loops are basic concept in Javascript as well as in Blogger. Just like we loop the array and access each item (using <b:loop>
tag), we can do the same with Blogger. But lambda expressions let us do processing with array without looping it.
Lambda expressions again works on the basic principle of if and else condition. Point to note that these new expressions work on a set of elements and practically Blogger have 3 sets only we can work on.
- Comments
- Labels
- Posts
- any
- all
- none
- count
- filter
- map
- first
<b:if cond='data:post.labels any (l => l.name in {"labela","labelb"})'>
...Code here...
</b:if>
<b:if cond='data:post.labels all (l => l.name not in {"labela","labelb"})'>
...Code here...
</b:if>
<b:if cond='data:post.labels all (l => l.name not in {"labela","labelb"})'>
...Code here...
</b:if>
<b:if cond='data:post.labels count (l => l.name not in {"labela","labelb"})'>
...Code here...
</b:if>
<b:loop values='data:posts filter (p => p.id != 0)' var='post'>
<h1>Post found: <data:post.title/></h1>
</b:loop>
<b:loop values='data:posts first(p => p.timestamp == "4.2.09")' var='post'>
<h1>Post found: <data:post.title/></h1>
</b:loop>
<b:loop values='data:post.labels map (l=> ">>" + l.name)' var='label'>
<h1><data:label/></h1>
</b:loop>
A final note: the article linked to suggests the Lambda's may only be applied to post, label and comment elements. It certainly works with the first two but I haven't tried it with comments.
Function Of Blogger :
resizeImage(data:post.firstImageUrl, 435, "2:3") // change size image with param : url, width, ratio
📁 Blogspot