meteor-jade icon indicating copy to clipboard operation
meteor-jade copied to clipboard

Propose: Just JADE feature

Open teintinu opened this issue 8 years ago • 7 comments

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
  });
}

teintinu avatar Sep 01 '15 14:09 teintinu

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.

mquandalle avatar Sep 01 '15 14:09 mquandalle

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

teintinu avatar Sep 01 '15 14:09 teintinu

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/

jakobrosenberg avatar Sep 11 '15 14:09 jakobrosenberg

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...

laurentpayot avatar Sep 12 '15 11:09 laurentpayot

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.

jakobrosenberg avatar Sep 12 '15 12:09 jakobrosenberg

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

laurentpayot avatar Sep 12 '15 14:09 laurentpayot

but what if we use coffeescript ?

crapthings avatar Sep 18 '15 17:09 crapthings