Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify render callback when adding templates #1

Open
taras opened this issue Mar 29, 2013 · 0 comments
Open

Specify render callback when adding templates #1

taras opened this issue Mar 29, 2013 · 0 comments

Comments

@taras
Copy link
Contributor

taras commented Mar 29, 2013

When you have many templates that each have to execute a callback before rendering, you ended up with something like this

    $main_menu = $this->add( 'template', array(
      'name'      => 'main_menu',
      'path'      => dirname( dirname( __FILE__ ) ) . '/templates',
      'template'  => '/main-menu.php',
    ));

    /**
     * Execute setup_main_menu before rendering main_menu template
     */
    $main_menu->add_action( 'render', array( $this, 'load_main_menu' ) );

    $featured = $this->add( 'template', array(
      'name'      => 'featured',
      'path'      => dirname( dirname( __FILE__ ) ) . '/templates',
      'template'  => '/featured.php',
    ));

    $featured->add_action( 'render', array( $this, 'load_main_menu' ) );

It would be easier and cleaner, if you could specify the render callback via $args

    $main_menu = $this->add( 'template', array(
      'name'      => 'main_menu',
      'path'      => dirname( dirname( __FILE__ ) ) . '/templates',
      'template'  => '/main-menu.php',
      'render'  => array( $this, 'load_main_menu' ),
    ));

    $featured_events = $this->add( 'template', array(
      'name'      => 'featured',
      'path'      => dirname( dirname( __FILE__ ) ) . '/templates',
      'template'  => '/featured.php',
      'render'  => array( $this, 'render_featured' ),
    ));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant