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

Adding template support on top of jsx #46

Open
chompomonim opened this issue Jan 4, 2016 · 3 comments
Open

Adding template support on top of jsx #46

chompomonim opened this issue Jan 4, 2016 · 3 comments

Comments

@chompomonim
Copy link

I like initial ideas of components based Blaze2 and what Blaze Components try to do. React may be much better platform to that that Blaze. I understand that fist of all you wanted to make people more easy way of moving they apps into react so you wanted to be as stict with Blaze API as possible. Have you any plans to add components support into sideburns?

I'd like to have code like this:

<template name="Page">
  <div class="page">
   <ul>
   {{#each person in people}}
       <li onClick={{this.clickEvent}}>Hello {{person.name}}</li>
    {{/each}}
   </ul>
  </div>
</template>

class Page extends React.Component {
  mixins: [ReactMeteorData],
  getMeteorData() {
    return {
      people() {
        return People.find();
      }
    }
  },
  clickEvent() {
    console.log('Hello world');
  },
  render() { return Template.Page }
}

Is it possible in any way?

@chompomonim chompomonim changed the title Why not just adding template support on top of normal React syntax Why not just adding template support on top of normal React syntax? Jan 4, 2016
@timbrandin
Copy link
Owner

I had this idea to, and we use this logic in the blaze component that all templates are based on, basically one also needs to pass down the component and the context (the data) for the template to work.

Though I have some ideas on simplifying the templates for a React only approach.

But also with Meteor the above strategy of single file code we need to either pick a new file extension or remove a package using one we want, I guess .jsx is the one we want in this case

@chompomonim
Copy link
Author

I think .jsx should work well. Even if we will have to remove jsx package.

BTW, I'm using .cjsx (for CoffeeScript), but it probably would be hard to have support for it :/
Code would look like:

<template name="Page">
  <div class="page">
   <ul>
   {{#each person in people}}
       <li onClick={{this.clickEvent}}>Hello {{person.name}}</li>
   {{/each}}
   </ul>
  </div>
</template>

class Page extends React.Component 
  mixins: [ReactMeteorData]
  getMeteorData: ->
    people: -> People.find()
  clickEvent: ->
    console.log('Hello world');
  render: -> Template.Page

@timbrandin
Copy link
Owner

This is the aim for the next release.

@timbrandin timbrandin changed the title Why not just adding template support on top of normal React syntax? Adding template support on top of normal React jsx. Jan 28, 2016
@timbrandin timbrandin changed the title Adding template support on top of normal React jsx. Adding template support on top jsx. Jan 28, 2016
@timbrandin timbrandin changed the title Adding template support on top jsx. Adding template support on top of jsx Jan 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants