New Parser Features — The Default Attribute

The new parser introduced into version 1.3 does everything the old parser could do, and more. Perhaps the most useful new feature is the default attribute. (Note: this is different from “attribute defaults” which were also in the old parser.)

If you have even posted comments in forums, you may have noticed that they usually provided a set of text formatting tags like [b], [i], and [quote], very much like embeds and WordPress shortcodes. The tags belong to a widely used tag language called BBCode, which is essentially a simplified version of HTML.

Most of the tag formatting and attribute rules are similar to HTML. For example, the quotation tag [quote] looks like this:

[quote name="Thomas Jefferson" date="July 4, 1776"]We hold
these truths to be self-evident: That all men are created
equal.[/quote]

This type of tag has attributes just like regular HTML and embeds, but there is also another version of the same tag:

[quote=Thomas Jefferson]We hold these truths to be
self-evident: That all men are created equal.[/quote]

In this case, where there is just one attribute, there really isn’t any need for the attribute name, so the name attribute becomes the default attribute for the tag. This is especially useful in tags that take just one parameter, like a [color] tag:

[color=green]

Or the link tag:

[link=http://yahoo.com]Yahoo Home Page[/link]

where the default attribute is used in combination with the content attribute (the text between the begin and end tags).

When you are using an embed often, and you only need one attribute value most of the time, as in the examples above, then this shorter tag format can save you a lot of typing.

So, how do you do this with the Embedder plugin?

Easy, once you have selected to use the new parser, simply use the reserved attribute name {$_default} somewhere in the embed’s value, like the example below defining an embed to generate a link:

<a href="{$_default}">{$_content}</a>

Now all you have to do is use it, like this:

[link=http://yahoo.com]Yahoo Home Page[/link]

Exactly the same as the BBCode example above, in fact.

That’s all there is to it. The only other important thing to remember is that the default attribute is only available with the new parser using the new attribute format, so don’t forget to set the option to use it in the Embeds settings page. (It is a global option, which means that all your embeds will be processed by the new parser when you select it.)

This entry was posted in Embedder Plugin. Bookmark the permalink.

One Response to New Parser Features — The Default Attribute

  1. I blog also and I’m creating something comparable to this specific article,
    “New Parser Features – The Default Attribute | moztools”.

    Do you really care if Iincorporate a number of of your own
    points? Regards ,Janice