Is there any support for Logical Operators in Blogger Templates?

319 views
Skip to first unread message

Alain-Christian

unread,
Mar 26, 2010, 7:36:03 PM3/26/10
to Blogger Template Design Group
Please say yes! Oh man, life would be so much easier. Sometimes I get
lost with all those nested Comparison Operators. Commenting helps me
keep track things but things don't always work out as expected.


More Info:
JavaScript Comparison and Logical Operators
http://www.w3schools.com/JS/js_comparisons.asp

Blogger Help: Widget Tags for Layouts
http://www.google.com/support/blogger/bin/answer.py?hl=en&answer=46995

Alain-Christian

unread,
Mar 26, 2010, 8:22:11 PM3/26/10
to Blogger Template Design Group
Well of course I tried it.

Test 1
<b:if cond="data:blog.searchQuery != &#34;&#34; ||
data:blog.searchQuery == &#34;TOAST&#34;">
<!--not equal null or equal TOAST-->
</b:if>

Result
Uploaded fine but I get this error on my pages
TEMPLATE ERROR: Extra characters at end of string: buf=[||]
remainder=[data:blog.searchQuery == "TOAST"]

Test 2
<b:if cond="data:blog.searchQuery || data:blog.title">
<!--data:blog.searchQuery or data:blog.title-->
</b:if>

Result
TEMPLATE ERROR: Extra characters at end of string: buf=[||]
remainder=[data:blog.title]

I tried it again with &amp;&amp; but got the same error except with
"buf=[&&]".

I'm really hoping I just did something wrong. :) Just imagine how but
be if we went from this:


<b:if cond="data:a">
<b:if cond="data:b">
<b:if cond="data:c">
<b:if cond="data:d">
*stuff*
</b:if>
</b:if>
</b:if>
</b:if>

TO THIS!!!

<b:if cond="data:a &amp;&amp; data:b &amp;&amp; data:c &amp;&amp;
data:d">
*stuff*
</b:if>


That's not even an exaggerated example. Well, my fingers are crossed.

On Mar 26, 7:36 pm, Alain-Christian <mynamebackwa...@gmail.com> wrote:
> Please say yes! Oh man, life would be so much easier. Sometimes I get
> lost with all those nested Comparison Operators. Commenting helps me
> keep track things but things don't always work out as expected.
>
> More Info:

> JavaScript Comparison and Logical Operatorshttp://www.w3schools.com/JS/js_comparisons.asp

jinwoo

unread,
Mar 27, 2010, 10:30:49 PM3/27/10
to Blogger Template Design Group
Hi Alain,

Thanks for the great suggestion!
We would also love to add those operators like &&, ||, etc. But our
current implementation of the template parser is a pretty simple one,
and adding those would be quite a lot of work. It's definitely on our
TODO list. And we keep on improving our template markup language. For
example, we recently added the "modulo" operator (%) to the supported
operators (previously only + and - were supported). Please stay tuned
until our higher priority tasks are complete :)

Jinwoo

Alain-Christian

unread,
Mar 28, 2010, 12:44:44 AM3/28/10
to Blogger Template Design Group
> We would also love to add those operators like &&, ||, etc.
Oh my God.

> It's definitely on our TODO list.

OH MY GOD.

> And we keep on improving our template markup language.

!!!!!

This is AMAZING news! Sure, take care of the other stuff first, that's
cool. You're spinning a lot of plates right now. The fact that you've
already been thinking about it and that it's on the list is just about
the greatest thing ever. I can't wait, it's totally going to be worth
it.


> For example, we recently added the "modulo" operator (%) to the supported operators (previously only + and - were supported).

I'm sorry, I don't understand. How do I use %, + and - in conditional
statements? I've never heard of modulo before and I'd be willing to
research its usage in my own time. I need to know how to format it
though. Same with - and +.

Thank you.

Jinwoo Lee

unread,
Mar 28, 2010, 2:05:43 AM3/28/10
to blogger-tem...@googlegroups.com
Thank you, Alain.

Using % will be best described by an example code. It may be useful when you want to do something for every N-th loop. For example, if you want to show the labels on your blog post and show 3 labels on each line, you can do like this:

    <b:loop values='data:post.labels var='label' index='idx'>
        <data:label.name/>
        <b:if cond='data:idx % 3 == 2'><br/></b:if>
    </b:loop>

This code puts <br/> for every 3rd label. The "index" variable of the loop starts from zero and is incremented for each loop (0, 1, 2, ...). So every 3rd index modulo 3 becomes 2. The "index" variable of the loop was also recently added to our markup language.

Hope this will be useful.

Thanks,
Jinwoo

To unsubscribe from this group, send email to blogger-template-design+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

Alain-Christian

unread,
Mar 28, 2010, 4:07:26 PM3/28/10
to Blogger Template Design Group
Oh boy, you've given me a lot to play around with. Thank you so much!

On Mar 28, 2:05 am, Jinwoo Lee <jin...@google.com> wrote:
> Thank you, Alain.
>
> Using % will be best described by an example code. It may be useful when you
> want to do something for every N-th loop. For example, if you want to show
> the labels on your blog post and show 3 labels on each line, you can do like
> this:
>
>     <b:loop values='data:post.labels var='label' index='idx'>
>         <data:label.name/>
>         <b:if cond='data:idx % 3 == 2'><br/></b:if>
>     </b:loop>
>
> This code puts <br/> for every 3rd label. The "index" variable of the loop
> starts from zero and is incremented for each loop (0, 1, 2, ...). So every
> 3rd index modulo 3 becomes 2. The "index" variable of the loop was also
> recently added to our markup language.
>
> Hope this will be useful.
>
> Thanks,
> Jinwoo
>
> On Sat, Mar 27, 2010 at 9:44 PM, Alain-Christian

> <mynamebackwa...@gmail.com>wrote:

Reply all
Reply to author
Forward
0 new messages