I'm trying to make Jade work with Meteor's Flow Router and Blaze. Somehow it doesn't work for me. I'm pretty sure it's just something small that I don't notice.
HTML versions of home.jade and layout.jade files give a proper, working result.
According to this, there used to be a problem, but it was solved in 0.2.9 release of mquandalle:jade.
$ meteor list
blaze 2.1.2 Meteor Reactive Templating library
kadira:blaze-layout 2.0.0 Layout Manager for Blaze (works well with FlowRou...
kadira:flow-router 2.3.0 Carefully Designed Client Side Router for Meteor
meteor-platform 1.2.2 Include a standard set of Meteor packages in your...
mquandalle:jade 0.4.3 Jade template language
layout.jade
template(name="layout")
+Template.dynamic(template="main")
home.jade
template(name="home")
p Looks like working!
routes.js
FlowRouter.route('/', {
name: 'home',
action: function() {
BlazeLayout.render('layout', {main: 'home'});
}
});
The result:
<body>
<div id="__blaze-root">
</div>
</body>
Indeed, it is just a subtle detail issue: you should not use quotes around the main parameter in your layout template:
template(name="layout")
+Template.dynamic(template=main)
Related
I've tried most of the packages from https://atmospherejs.com/ but nothing seems to work with Meteor 1.3. Are there any editors for Meteor somewhat like Wordpress's TinyMCE?
I'm using React with Meteor and ES6. Trying to make a blog like CMS for myself.
(I've just started Meteor so I'm a noob in this platform)
TinyMCE got their own React module which worked for me - TinyMCE React
If anyone gets an error like: tinymce is not defined...
You can do-
Add a script in your footer :
src="//cdn.tinymce.com/4/tinymce.min.js"
Copy the whole script into your code, so that Meteor could merge it
for you
Add the script on a component level using dangerouslySetInnerHTML
function inside componentDidMount or anywhere you want
I have installed the semantic:ui 1.12.1 package. I can't use semantic's modals. It throws an error;
$dimmer.on is not a function
at Object.$.fn.modal.$allModules.each.module.set.clickaway
dimmer is true in client/lib/custom.semantic.json.
I tried installing semantic:ui-dimmer 1.12.0, but it didn't help.
Other parts of semantic appear to be working, how do I get semantic-ui modals to work in Meteor?
What is the correct way to use Meteor with Modernizr?
I'd like to use modernizr-meteor, but don't know how it works or how to customize it. Do I simple get a custom build off modernizr, and then merge the js file with the latests yepnope.js
Since Modernizr needs a no-js class in the html, I can simply add the class in on startup.
in /lib/startup.js
Meteor.startup(function() {
$('html').attr('class', 'no-js');
});
The correct way to use 3rd party libraries with Meteor is to install them from Meteor's package repository, Atmosphere.
A search for Modernizr reveals two packages. As a rule, packages with mrt in the organization name (the part before :) were automatically migrated, and generally out of date. They should be flagged.
The other package looks like a decent (not ideal) candidate, so you'd run:
meteor add cwaring:modernizr
I don't need jquery in my meteor app. When I type meteor remove jquery, answer is jquery: not in project.
But jquery is still attached in html.
Meteor internals (domutils) depends on JQuery, but I believe the plan is to remove that dependency at some stage:
See: https://groups.google.com/forum/?fromgroups=#!topic/meteor-talk/21y9NbM9v90
Domutils seems to be able to cope without jQuery if sizzle is present (see findAllBySelector).
Doing a quick scan of the code I didn't see any other uses (other than on the server side - in the less parser).
To remove/replace jQuery with another version (2.x or 3.x).
Clone jquery package from official sources into your project folder /packages.
Replace contents of jquery.js with anything.
Downloaded package will have a higher priority and will be used instead of original one. Do on your own risk.
This is how I remove jQuery from Meteor.
Make sure your code really doesn't depend on jQuery before doing this. Also adding any Meteor packages depending on jQuery won't work as expected anymore (e.g: materialize:materialize).
So, if you want to make sure jQuery is removed from Meteor no matter what, just put
Package.describe({
summary: "Remove jQuery from meteor",
name: "jquery",
version: '1.999.999',
});
into packages/jquery/package.js. No need to clone. No need to add any other files.
Check your .meteor/versions file for the entry:
jquery#1.999.999
to confirm it worked.
In the Meteor FAQs http://meteor.com/faq/how-do-i-package-a-new-templating-system there is some information about adding a different (than the default Handlebars) templating system. Jade is the only other example explicitly called out elsewhere in the docs.
So is somebody already working on Jade? If not, is it feasible for me to start? Or is it still too early? e.g. :
The package API is rapidly changing and isn't documented, so you can't
make your own packages just yet. Coming soon.
I've been trying to love Handlebars in my current Ember.js project, but for me nothing is as elegant as Jade.
We would love to see Jade integration. Use packages/handlebars as a template.
The basic strategy is to wire the output of the template engine into Meteor.ui.render which is how we implement live page updates. As long as your template returns HTML, that'll work. Any time a Jade template references a Meteor.Collection document or Session variable, Meteor will register that dependency so that knows to rerender the template when the data changes.
Even better, though, is to also use Meteor.ui.chunk and Meteor.ui.listChunk. These will limit the amount of recalculation Meteor has to do when there's a change. For example, if you are rendering a list of documents using {{#each}} in Handlebars-speak, there's no reason to recalculate the whole template when a new document enters the result set. We just render one HTML chunk for the new document, and insert that right into the DOM. That's listChunk in action.
So you'll likely find that instrumenting just if/unless and for/each in Jade gets you a long way there.
Just be aware, package development is not as documented as the other parts of the system. So don't hesitate to ask more specific questions as you go.
meteor >= 0.8.0
Using the mquandalle:jade package has been officially recommended.
meteor <= 0.7.2
If you are not using CoffeeScript, you should check out jade-handlebars. As of this writing, there is an issue where CoffeeScript template files seem to need to be wrapped inside a Meteor.startup function which caused other issues for me.
If you are using CoffeeScript, you should check out my Cakefile. The details are all in the description, but the short version is that it automatically adds/removes/updates html files alongside your jade files. I ended up adding *.html to my .gitignore, which only works if you are not mixing html and jade in the same project. It's a bit of a hack but so far it's working fine for me.
Just publish my first meteor smart package on Atmosphere!
Use Jade+Handlebars instead of HTML+Handlebars
https://atmosphere.meteor.com/package/jade-handlebars
Just got jade templating working with my Meteor projects! And it is actual jade not jade-handlebars or some half form of jade. It is great but it needs Meteor UI which is currently in a development release called blaze-rc1. So it does not work with Meteor 0.7 at the moment.
do 'mrt add jade'
&
Run your meteor project using 'mrt --release blaze-rc1'
https://github.com/mquandalle/meteor-jade/
If you have coffeescript and jade files in the same folder add _ to the beginning of the file name so it loads jade files before the coffeescript file, otherwise it will not work correctly.
mrt add jade
in client/views/templates/hello.jade you could do something like this:
template(name="hello")
h1 hello world!
{{greeting}}
input(type="button" value="click")
start you app with mrt