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

Allow view options override on handler object #1856

Merged
merged 1 commit into from Aug 13, 2014
Merged

Allow view options override on handler object #1856

merged 1 commit into from Aug 13, 2014

Conversation

@jas
Copy link
Contributor

@jas jas commented Aug 13, 2014

This pull request allows view options to be overridden in the handler object for a particular response. Previously, the reply.view method had to be used.

This is useful for specifying a different layout template for a particular route.

{
  method: 'GET',
  path: '/',
  handler: {
    view: {
      template: 'homepage',
      options: {
        layout: 'specialLayoutForHomepage'
      }
    }
  }
}

Another use case is setting custom runtimeOptions for a particular route. Example:

var homepageViewOptions = {
  runtimeOptions: {
    // Handlebars allows helpers to be passed to the function returned from "compile"
    helpers: {
      uppercase: function(context) {
        return context.toUpperCase();
      }
    }
  }
};

...

{
  method: 'GET',
  path: '/',
  handler: {
    view: {
      template: 'homepage',
      options: homepageViewOptions
    }
  }
}
@jas jas changed the title Allow custom runtime options for views on handler object Allow view options override on handler object Aug 13, 2014
@hueniverse
Copy link
Contributor

@hueniverse hueniverse commented Aug 13, 2014

Can you edit the issue description to add some context on what you are trying to do and how this fixes it?

@hueniverse hueniverse self-assigned this Aug 13, 2014
@jas
Copy link
Contributor Author

@jas jas commented Aug 13, 2014

Sure thing; updated. I also added the options object to the Reference doc.

@hueniverse hueniverse added this to the 6.5.2 milestone Aug 13, 2014
hueniverse pushed a commit that referenced this issue Aug 13, 2014
Allow view options override on handler object
@hueniverse hueniverse merged commit 355d45f into hapijs:master Aug 13, 2014
1 check failed
@jmonster
Copy link
Contributor

@jmonster jmonster commented Aug 14, 2014

That got merged fast, thank you both!

@lock
Copy link

@lock lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants