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

Making regions more usable. #11

Open
tmeasday opened this issue Apr 11, 2014 · 5 comments
Open

Making regions more usable. #11

tmeasday opened this issue Apr 11, 2014 · 5 comments

Comments

@tmeasday
Copy link
Contributor

Howdy @cmather

So I'm working on converting Verso over to BL and it makes heavy use of layouts. One thing that we used to do with our old janky layouts system was bind helpers to regions. So something like

<template name="somePage">
  {{#Layout template='pageLayout' title=title}}
    ...
  {{/Layout}}
</template>

<template name="pageLayout">
  <h1>{{> yield region='title'}}</h1>
 {{> yield}}
</template>
Template.somePage.title = function() { return 'Dashboard'; }

So essentially we are passing the content for a region in via the arguments to {{#Layout.

What do you think?

Related ideas:

  • set a region content to a template in a similar way? titleTemplate='foo' perhaps?
  • remove the need for the redundant feeling title=title and just automatically search for a helper named title when trying to {{> yield region='title'}} if no content is set for that region.

Happy to implement whatever (actually I'll probably implement the first thing right now in a branch) if you agree on the API..

tmeasday added a commit that referenced this issue Apr 11, 2014
@tmeasday
Copy link
Contributor Author

I went ahead and did this an added {{> yield region='foo' text='true'}} to deal with differentiating between setting templates and setting text. Let's discuss soon :)

@cmather
Copy link
Owner

cmather commented Apr 11, 2014

Hey @tmeasday! Sorry for the delay. I'm trying to understand the idea but not sure I'm getting it. So, in the first example, are you trying to set the content for the 'title' region by passing its value as an argument to Layout? Where does title's value from from? Is it dynamic? Why go through the trouble of creating a yield region in this case vs. just putting some dynamic content in the layout. What am I missing :)?

@tmeasday
Copy link
Contributor Author

Hey @cmather. I'll try to be clearer about the base use case and then perhaps my comments above will make more sense.

We're using layouts to wrap the contents of a template in standard boilerplate. As an example, the title of the page is included in the boilerplate. For some pages, the title is fixed -- for others it's dynamic. I was talking about a case where the title is dynamic, and thus a helper on the outer template (Template.somePage.title above).

With the current API, we could just do:

<template name="somePage">
  {{#Layout template='pageLayout}}
    {{#contentFor region='title'}}{{title}}{{/contentFor}}
   {{/Layout}}
</template>

But I'm looking for a way to set the content or template (both are important) for a region more directly when calling {{#Layout.

@tmeasday
Copy link
Contributor Author

I realise you probably haven't had time to think about this, but when you can circle back round I have a quick qn in regards to this:

If I render a layout with helper argument (like {{#Layout regionX=helper}}), how does the component receive notice when helper changes?

It doesn't seem like this.get('regionX') is what I'm looking for here - it doesn't seem to be reactive and change when helper changes. But this must work somehow... or is this a limitation of blaze?

@cmather
Copy link
Owner

cmather commented Apr 26, 2014

Might be a limitation if I recall. I Need to check though.

On Apr 24, 2014, at 11:33 PM, Tom Coleman [email protected] wrote:

I realise you probably haven't had time to think about this, but when you can circle back round I have a quick qn in regards to this:

If I render a layout with helper argument (like {{#Layout regionX=helper}}), how does the component receive notice when helper changes?

It doesn't seem like this.get('regionX') is what I'm looking for here - it doesn't seem to be reactive and change when helper changes. But this must work somehow... or is this a limitation of blaze?


Reply to this email directly or view it on GitHub.

tmeasday added a commit that referenced this issue May 1, 2014
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

2 participants