Creating template fields such as {{email}} and {{website}}?

Is it at all possible to add template fields in your content or will this need to be built on top of kirby?

For example, rather than have this in my content:

Hi Thank you for query please <a href="mailto:somemail@gmail.com">email me</a>

Is it possible to do

Hi Thank you for your query please {{email}}

And have it reference whatever I set {{email}} to?

You could create custom Kirby Tags

Also, there is an email Kirbytag which you can use as follows:

``text
(email: bastian@getkirby.com)
(email: bastian@getkirby.com text: Send me an email)
(email: bastian@getkirby.com text: Send me an email title: Contact me)
(email: bastian@getkirby.com text: Send me an email class: email)


Or better still, you can use Kirbytext filters: http://getkirby.com/docs/advanced/kirbytext

Cool, thanks for the answers! :slight_smile:

Yes, I know that is late, but you can also use a filter like this:

/**
 * Adds support for use placeholders like {foo} in your fields
 * 
 * <code>
 * 
 * $placeholders = array(
 *  'foo' => 'value',
 *  'bar' => 'value',
 * );
 * 
 * echo $page->yourfield()->template($placeholders)->kirbytext();
 * 
 * </code>
 * 
 * @param Field $field The calling Kirby Field instance
 * @param Array $array A key/value array
 * @author fenixkim
 */
field::$methods['template'] = function($field, $array) {
  
  $field->value = str::template($field->value, $array);
  
  return $field;
};