mquandalle / meteor-jade

The Jade template engine for Meteor/Blaze
http://atmospherejs.com/mquandalle/jade
MIT License
307 stars 39 forks source link

Propose: Just JADE feature #164

Open teintinu opened 9 years ago

teintinu commented 9 years ago

The idea is that a single jade file generates all the code needed to Meteor. At least the client side.

For example, something like that:

sample.jade

head
  title Sample
body
  h1 Welcome to Meteor!
  +hello
script(isClient).
  Session.setDefault('counter', 0);
script(isServer).
  Meteor.startup(function () {
    // code to run on server at startup
  });

template(name="hello")
  button Click Me
  p You've pressed the button {{counter}} times.
  script(helper="counter").
      return Session.get('counter');
  script(event="click button").
      // increment the counter when button is clicked
      Session.set('counter', Session.get('counter') + 1);

will generate something like this:

sample.html

<head>
  <title>Sample</title>
</head>

<body>
  <h1>Welcome to Meteor!</h1>

  {{> hello}}
</body>

<template name="hello">
  <button>Click Me</button>
  <p>You've pressed the button {{counter}} times.</p>
</template>

sample.js

if (Meteor.isClient) {
  // counter starts at 0
  Session.setDefault('counter', 0);

  Template.hello.helpers({
    counter: function () {
      return Session.get('counter');
    }
  });

  Template.hello.events({
    'click button': function () {
      // increment the counter when button is clicked
      Session.set('counter', Session.get('counter') + 1);
    }
  });
}

if (Meteor.isServer) {
  Meteor.startup(function () {
    // code to run on server at startup
  });
}
mquandalle commented 9 years ago

So basically the idea would be to support script tag I guess. This is similar to what http://riotjs.com/ does for instance. I'm waiting for more feedback from users.

teintinu commented 9 years ago

Yes, it's similar to riotjs. Ok, after you decide, If I can help you something just call me.

jakobrosenberg commented 9 years ago

I'd love a react/riot-like approach for Meteor. React feels too big and riot doesn't like Meteor much. If you could make something similar, Jade would be the cherry on top.

At a glance riot seems to support Jade as well. http://riotjs.com/guide/compiler/

laurentpayot commented 9 years ago

I don't understand the hype around mixing view code and controller code. Seems like a step back to me, maybe younger coders never had to deal with the issues that come with it. Some friends had big problems maintaining react "soup-code" recently...

jakobrosenberg commented 9 years ago

To each their own. I personally feel components are often too scattered throughout Meteor. postPublish.js, postSubscribe.js, postCollection.js, postMethods.js, postsList.js, postsList.html, postsList.css, postView.js, postView.html, postView.css, etc. etc.

I prefer separation of components over separation of technologies.

laurentpayot commented 9 years ago

I see what you mean. For now I'm just waiting for web components to arrive to see if they are less messy.

crapthings commented 9 years ago

but what if we use coffeescript ?