Montag, 27. Juli 2015

blogspot - neue Programmier-Ausdrücke für Blogger-Templates

Even more expansions to the Blogger template language

meldete im Mai das blogger-team von google auf "Blogger Buzz"
 
Neue Befehle also, z.B. das b:elesif , das bisher fehlte und für mehrfache if-Verschachtelungen gut ist. Auch die von anderen Programmiersprachen her bekannte switch-case Kombination wurde eingeführt. Interessant dürfte ferner der b:eval Ausdruck sein.

Eigentlich kann man mit den xml-Templates von blogger/blogspot erstaunlich viel experimentieren und variieren. Man benötigt nicht unbedingt php, wie es wordpress und Co verwenden.
 
 
Originaltexte: 
 
Recently we introduced a new set of expressions to the Blogger templating language, designed to let you customize the HTML of each post and page on your blog. We’ve gotten great feedback on them, so we figured we'd offer even more.

Now you can try out new tags, like:

  • b:elseif for a simpler multiple-case b:if branch.
  • b:switch and b:case for succinctly handling several possible cases of a variable.
  • b:eval for evaluation of more complex expressions involving data variables.
  • b:with for creating a nicer variable alias for a calculated value.

An example of customizing the markup of your blog, using the new switch tags.


If you’d like to customize your blog's template using these tags and expressions, just head to the dashboard under Settings > Template > Edit HTML.


You can customize your blog's template under Settings > Template > Edit HTML.




Previously, the expressions in Blogger's templates could
  • Add or concatenate values with +
  • Subtract values with -
  • Check for equality with != and ==
  • Compare values with <, >, <= and >=

Now, support has been added for many more expression operators, including:
  • Inversion of true/false values with !/not e.g. <b:if cond='!data:post.allowComments'>...
  • Picking between 2 values with ?: e.g. <a expr:class='data:post.allowComments ? "comments" : "no-comments"' ...
  • Checking if a value is a member of a set or array, with in/contains e.g. <b:if cond='data:blog.pageType in {"index", "archive"}'>...
  • Combining multiple conditions with and/or e.g. <b:if cond='data:blog.pageType == "index" and data:post.allowComments'>...
  • Changing the order of operations with () e.g. <div expr:style='"max-width: " + (data:width + 10) + "px;"'>...

For a full specification of the new operators, see the help article.
Happy Templating!


Posted by Luke Bjerring, Software Engineer

  © Blogger template 'Fly Away' by Ourblogtemplates.com 2008

Back to TOP