-
Notifications
You must be signed in to change notification settings - Fork 38
Anonymous helper functions AKA Inline JavaScript expressions #176
Conversation
This is what simple-todos looks like for me while still working: simple-todos.jade: head
title Todo List
body
.container
header
h1 Todo List (#{Tasks.find({checked: {$ne: true}}).count()})
label.hide-completed
input(type="checkbox" checked="#{Session.get('hideCompleted')}")
| Hide Completed Tasks
+loginButtons
if currentUser
form.new-task
input(type="text" name="text" placeholder="Type to add new tasks!")
ul
each tasks
+task task.tpl.jade: li(class="{{#if checked}}checked{{/if}} {{#if private}}private{{/if}}")
button.delete ×
input.toggle-checked(type="checkbox" checked=checked)
if this.owner==Meteor.userId()
button.toggle-private
if private
| Private
else
| Public
span.text <strong>#{username}</strong> - #{text} |
Hey @xiphias, thank you for this PR, we finally get a chance to fix issue n° #1 :-) I will have to do a careful review of the code before merging. Could you please add a few comments in the code before I dig in? Also as you noticed, this feature definitely needs more tests, but we can do that in parallel. |
Sure, I'll write some comments. |
@@ -30,3 +30,49 @@ Tinytest.add("JadeCompiler - compile templates", function(test) { | |||
test.equal(JadeCompiler.compile(template), | |||
"(function() {\n return HTML.P(\"hello world\");\n})"); | |||
}); | |||
|
|||
var template3 = wrapInTemplate("hello", | |||
["if helper arg1 arg2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can use ES6 template string here, just add the meteor ecmascript
package and replace "
by `.
I added the comments, switched to ES6 and fixed Travis build. |
A limitation that I found is that the mixins can't have too complex JavaScript..I guess Jade Lexer needs to be modified for that. |
This is excellent! +1 |
Hey @mquandalle, I added some bug fixes and better tests, could you please take another look at the pull request? |
Sure! Also @dalgard, I haven’t reviewed your fork yet but did you implement something similar? Do you have an opinion on this? |
Oh, hi @mquandalle – welcome back! :) I haven't implemented inline JavaScript expressions – I think it's a really bad idea. As I've written elsewhere, the templating paradigm that Blaze builds upon is a logicless one – it is not in my opinion desirable to embed JavaScript in Blaze templates, quite the contrary. The only thing I would recommend is for @xiphias to create another package that extends this one. |
I have no problem with having a separate package if you don't like the direction. I don't really like the MVC separation that most systems use, and prefer to write logic and UI at the same place, but I also acknowledge that it's not the mainstream software design philosophy. Reactivity in Meteor partly makes the separation of controller and view unnecessary, and in my view having view and event logic in the jade templates make the code easier to maintain, for a non-designer programmer. It also makes it harder for non-programmer designers, but I don't generally work with designers who modify my templates. So it's up to you to make the decision. |
@xiphias: I totally agree with you in the sense that React is a nice addition to Meteor, and that I hope that Blaze 2 will embrace some kind of JSX style. But I don't think these concepts should be brought into Jade/Spacebars. |
I'm not really talking about React/JSX, which has it's own disadvantages. Anyways, if the decision by @mquandalle is not having this patch either and other people are not interested, I'll probably just create some new features for myself without going through commenting & preparing for submission again. |
@mquandalle I added anonymous events as well, please check it if you like it. I think it simplifies Meteor development a lot. You can check the simple-todos implementation with the new features here in the README: |
Thanks very much, I'll do that and update here.
|
Thanks for the help, I found the problem with the build machines: I needed to add the right coffee-script npm dependency (it's interesting that after that I added it, it seems that the build machine is not necessary). Could you please try the newest version? (xiphy:jade-coffee@0.1.4) |
Hello @xiphias , The point of the build machines (that we get access to for free, which is a pretty good deal; as 5 minutes of AWS time every few days can add up to $10 or so, it's not a small cost for the end developers without servers to test on) is explained pretty well in the Build Machines page. And specifically this following section is important in this case: Why is it important to use pre-configured build-machines. Why shouldn't I just publish from my laptop? |
Hey, @AlbinoGeek, Also I think that as I have a windows machine, and I haven't downloaded 4 cross-compilers on it, maybe meteor publish already does this. The only problem was that the error messages on the build machines weren't displayed when I was using meteor publish, so I didn't know what's the problem. |
Hi @xiphias , It turns out this is intentional (or at least known behaviour) as of posts such as This particular closed issue on Meteor's GitHub that explains that if a platform agnostic package already exists (i.e: Meteor detected no platform-specific code), then you may have an "all platforms" package published already (IsoPack) Nothing wrong with that, and your builds work now on my projects :). Good one. (If your package has no platform-specific code, no additional work is required to build the package other than compiling it on a single target machine, and Meteor will automatically create the required IsoPack for all platforms from this file.) Only if Meteor detects that your package (or dependency chain) contains platform-specific code, then the build servers may be required again. |
Thanks! If you have experience in Meteor development and like the extension (but On Mon, Oct 26, 2015 at 4:53 PM, Damon Blais notifications@github.com
|
@xiphias Sure, any means we can communicate other than this thread? I don't want other to be notified on our conversation about jade-coffee :). mail via: (my github username) (at) gmail (dot) com , would work. |
Conflicts: README.md packages/jade-coffee/package.js packages/jade-compiler/package.js packages/jade/plugin/handler.js
@mquandalle We're merging in all changes from mquandalle:master branch back into xiphias:master , this PR might have many less differences soon. |
Merge with Upstream: mquandalle/meteor-jade
Right, I'll work towards fixing some of those 162 linter errors, heh. |
If you have a modern version of |
This still can't be merged, handler.js changes in 1.2 have not been implemented yet. See: Commit 215a966 And thanks for the heads up on eslint. |
Closing, because this is too old and can’t be merged. |
I spent some time having fun implementing this feature, which creates anonymous helper functions.
It works well enough, although better and more unit tests are needed that can test the created functions.
It works with templates and files as well, and works with #{} and !{} syntax and if markups.
The next logical step would be anonymous events (and inlne coffeescript support), but that doesn't belong to this CL.