Skip to content

Instantly share code, notes, and snippets.

@willert
Created March 4, 2014 18:59
Show Gist options
  • Save willert/9353205 to your computer and use it in GitHub Desktop.
Save willert/9353205 to your computer and use it in GitHub Desktop.
A complete base class for mason widgets (recipe.mp)
has item => ();
has visits => ();
has fav_map => ();
has search_string => ( default => '' );
has force_tab => ();
has uri => ( init_arg => undef, default => method () {
my $uri = URI->new( $.item->get_uri . $.search_string );
$uri->query_param( foo => $.force_tab ) if $.force_tab;
$uri;
});
method display_balance_symbols () {
$m->comp( 'balance_symbols.mi', symbols => $.item->balance_symbols );
}
@willert
Copy link
Author

willert commented Mar 4, 2014

Usage:

<%flags> extends => '../generic/recipe.mp' </%flags>

<div class="rezept">
   <a href="[% $.uri %]" title="Rezept anschauen">
       <div class="image">
          <div class="image_holder">
              <div class="image_bg">
              [...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment