Not a developer? Go to MovableType.com

Plugin and Theme Directory

Text Macros

By Byrne Reese
Posted October 5, 2010, in Developer.

Details

This plugin provides a framework for developers to create really simple text macros that can processed inside of text. What is a macro? Well imagine you need a way of embedding within an entry some dynamic text, like the URL to page elsewhere on the site. Suppose you don't know the actual URL or the URL may actually change, but you do know the page's ID. So using this plugin you can embed the following text inside of an entry:

[% PageURL id="32" %]

Installation

To install this plugin follow the instructions found here:

http://tinyurl.com/easy-plugin-install

Supported Macros

  • PageURL - takes a single argument id which identifies the page for which to generate a URL for.

Need another macro, but don't know how to build one yourself? At Endevver, we'll create one for you. And if it is simple, which it probably will be, we'll do it for free. We're that nice. Yes we are. Visit our help center to submit your request.

Enabling Macros

To turn on the text macro capabilities you need to add the following attribute to any template tag: text_macros="1".

You can easily encapsulate any text output by a template and enable macros for large blocks like so:

[% PageURL id="3" %]

Macro Syntax

Macros are bounded by an opening [% and a closing %]. They cannot encapsulate text. They are only tokens that will be substituted by a text value later.

Arguments not recognized by a macro will be ignored.

Examples

The following are all acceptable syntaxes for the same tag.

  • [% PageURL id="3" %]
  • [%PageURL id="3"%]
  • [%pageurl id="3" ignore_me="foo"%]

Known Issue

Macros that do not have a handler defined for them will have a blank string substituted in their place.

Developer Guide

Creating New Macros - Writing a Handler

Handlers for new macros are defined in a plugin's config.yaml under the text_macros key. Each macro specifies a handler for processing input. Each handler takes as input a single argument in the form of a hash containing the arguments passed into the tag.

Example

In your plugin define the following in the registry:

id: MyPlugin
name: 'My Plugin'
text_macros: 
  PageURL: $MyPlugin::MyPlugin::macro_page_url

Then create the following library file plugins/MyPlugin/lib/MyPlugin.pm and in it create the following subroutine:

sub macro_page_url {
  my ($args) = @_;
  my $page;
  if ($args->{'id'}) {
      $page = MT->model('page')->load( $args->{'id'} );
  } elsif ($args->{'basename'}) {
      $page = MT->model('page')->load({ basename => $args->{'basename'} });
  }
  return $page->permalink;
}

Frequently Asked Questions

Does Text Macros work with any MT template tag and if so how is this different from mteval?

Text Macros is a distinct "language" from the more powerful templating language that powers Movable Type and Melody. The reason we developed these macros was in order to create a much simpler and more constrained way of injecting dynamically generated content into an entry. We could have used the MTEval plugin, but we ultimately felt that the MT templating language is too verbose, and for simple tasks, like embedding a URL to a page requires too much knowledge.

Help, Bugs and Feature Requests

If you are having problems installing or using the plugin, or if you would like to request us to implement a new macro to add to this pack, please check out our general knowledge base and help ticket system at help.endevver.com.

License

Perl Artistic


Back

17 Comments

binasa

binasa on August 17, 2017, 6:32 p.m. Reply

Borrow up to 50,000 from the bookie so you can carry on racing (subject to 17. download torrent This Firefox extension boosts the capabilities of your mouse, particularly as you surf, but configuration may be overwhelming.

binasa

binasa on October 26, 2017, 10:36 a.m. Reply

Show off a little!) TEXT A SHOPPING LIST! Use the app for texting recipes too. bestdownloadwarezdatabase.us Parents directly control what memories get added to a childs timeline and what information their friends and family can see.

Caroline11

Caroline11 on March 13, 2018, 10:49 a.m. Reply

Happy to come here.

Caroline11

Caroline11 on March 13, 2018, 10:51 a.m. Reply

Most relevant and good piece of content about updatenping you like to added here. I really enjoyed such content which help a lot to have unique approach. Infect, this article cause to solve my current assignment. I would like to say great thanks for this article. Any how, I need chief essays but here is the good information regarding different tools found here.

Vera Konrad

Vera Konrad on May 5, 2018, 2:59 p.m. Reply

Agent Orange. A world-class hybrid known for it’s potent orange aftertaste and extremely large, resinous buds. A very strong natural producer, Agent Orange is great for growers looking for a low-maintenance plant that will deliver. Agent Orange is a Hybrid marijuana strain with a distinct orange flavor. Agent Orange leaves you feeling energetic, and can help manage anxiety and stress.

ritariya

ritariya on June 1, 2018, 12:22 p.m. Reply

It provides a framework for developers to create really simple text macros. You can add any attribute to the text macros. Macros are bounded by opening and closing. They are only the tokes that were substituted by the value. They specifies as a handler for processing unit.<a href="https://www.suttoninhomeseniorcare.com">in home care</a>
Carolina Emory

Carolina Emory on July 31, 2018, 9:33 p.m. Reply

it sounds like precisely what you’re searching for. You can characterize particular bits of text for it to search for while at SilvertailProperties the same time you’re composing and supplant them with a decent scope of various stuff, from only an alternate piece of content to designed content, to the date or time, to pictures, to whatever’s on the clipboard right then and there, to directions to move the addition point around.

Carolina Emory

Carolina Emory on July 31, 2018, 9:39 p.m. Reply

it sounds like precisely what you’re searching for. You can characterize particular bits of text for it to search for while at SilvertailProperties the same time you’re composing and supplant them with a decent scope of various stuff, from only an alternate piece of content to designed content, to the date or time, to pictures, to whatever’s on the clipboard right then and there, to directions to move the addition point around.

Carolina Emory

Carolina Emory on July 31, 2018, 9:43 p.m. Reply

it sounds like precisely what you’re searching for. You can characterize particular bits of text for it to search for while at the same time you’re composing and supplant them with a decent scope of various stuff, from only an alternate piece of content to designed content, SilvertailProperties to the date or time, to pictures, to whatever’s on the clipboard right then and there, to directions to move the addition point around.

Tyagi Ji

Tyagi Ji on October 5, 2018, 8:58 a.m. Reply

Here you will be able to know that we are going to share one of the best portal spider solitaire card games as you can enjoy these games online directly without any sign in process so try out for once surely you will not wish to quit these games.

Leila

Leila on October 21, 2018, 2:48 p.m. Reply

My IT guy in lawn services columbia sc just told me this and I was amazed by how important this plug-in is for my computer!

john888

john888 on October 21, 2018, 2:53 p.m. Reply

Interesting post. arcade games

john888

john888 on October 21, 2018, 2:54 p.m. Reply

Really nice and interesting post. puzzle games

john888

john888 on October 22, 2018, 2:30 p.m. Reply

Visit us home

john888

john888 on October 22, 2018, 2:31 p.m. Reply

Click here home

zianida

zianida on November 18, 2018, 8:01 p.m. Reply

toko online tas murah bandung hanya bayar untuk hasil services fanpage kami iklan video lihat di sini koleksinya google display network toko online search toko online get toko online izito toko online jual sling bag toko tas kipling murah bandung untuk koleksi koleksi produk terkini di murah tas toko tas online tas wanita murah kekinian jual sling bag untuk koleksi koleksi produk terkini di murah tas wanita murah dijual di toko jual tas ransel wanita tas online kami halaman web kami 08161672703 whatsapp sms call bbm pin bbm 7c2a2fa1 dapatkan koleksi tas korea dengan model tas wanita terbaru sesuai dengan harga grosir tas harga tas tote bag branded eceran toko tas online jual tas murah berkualitas indonesia tas indonesia tas indonesia adalah toko tas online yang menyediakan informasi tas dan menjual berbagai harga cath kidston macam produk tas yang merupakan hasil produksi dalam negeri dimana lokasi fashion terkininya di daerah cibaduyut kota bandung propinsi jawa barat negara indonesia online grosir tas sekolah anak di bandung shop toko grosir tas wanita murah di purwokerto toko grosir tas murah online shop menjual tas wanita online maupun offline di purwokerto pusat toko tas murah yang sudah berdiri toko tas cath kidston ransel mini sejak 2010 trusted online shop jual jual tas pesta beli harga murah di toko online aneka tas fashion wanita jual jual tas pesta tas pesta murah fsm 001 jual tas pesta murah model jual tas ransel mini kanvas lucu gambar merek garsel fashion harga murah warna crem ukuran all size katalog 2016 2017 katalog 2016 2017 beli grosir dan ecer sekarang di toko online duta online shop tas branded

Leave a Comment

Byrne Reese

Byrne Reese was previously the Product Manager of Movable Type at Six Apart, where he had also held positions as the Manager of Platform Technology and Product Manager for TypePad. Byrne is a huge supporter of the Movable Type user and developer community. He dedicates much of his time to promoting and educating people about Movable Type as well as building the tools and plugins for Movable Type that are showcased on Majordojo. He contributes regularly to open source; and he is an advocate for open protocols and standards like Atom and OpenID.

Website: http://profile.typekey.com/byrnereese