How do we write document level coffeescript in jade-handlebars ?? In jade file I used following
template(name="hellow")
:coffeescript
alert('helloworld')
But it gives error. Help me out guys
ERROR
Error: Cannot find module 'coffee-script'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at module.exports.coffeescript (/home/rohan/.meteorite/packages/jade-handlebars/jrhone/meteor-jade-handlebars/e442fecedeac64b81a0865e1b195a630181a3ee4/jade/lib/filters.js:93:14)
at Object.Compiler.visitFilter (/home/rohan/.meteorite/packages/jade-handlebars/jrhone/meteor-jade-handlebars/e442fecedeac64b81a0865e1b195a630181a3ee4/jade/lib/compiler.js:419:28)
at Object.Compiler.visitNode (/home/rohan/.meteorite/packages/jade-handlebars/jrhone/meteor-jade-handlebars/e442fecedeac64b81a0865e1b195a630181a3ee4/jade/lib/compiler.js:176:32)
at Object.Compiler.visit (/home/rohan/.meteorite/packages/jade-handlebars/jrhone/meteor-jade-handlebars/e442fecedeac64b81a0865e1b195a630181a3ee4/jade/lib/compiler.js:161:10)
at Object.Compiler.visitBlock (/home/rohan/.meteorite/packages/jade-handlebars/jrhone/meteor-jade-handlebars/e442fecedeac64b81a0865e1b195a630181a3ee4/jade/lib/compiler.js:253:12)
at Object.Compiler.visitNode (/home/rohan/.meteorite/packages/jade-handlebars/jrhone/meteor-jade-handlebars/e442fecedeac64b81a0865e1b195a630181a3ee4/jade/lib/compiler.js:176:32)
at Object.Compiler.visit (/home/rohan/.meteorite/packages/jade-handlebars/jrhone/meteor-jade-handlebars/e442fecedeac64b81a0865e1b195a630181a3ee4/jade/lib/compiler.js:161:10)
at Object.Compiler.visitTag (/home/rohan/.meteorite/packages/jade-handlebars/jrhone/meteor-jade-handlebars/e442fecedeac64b81a0865e1b195a630181a3ee4/jade/lib/compiler.js:390:12)
at Object.Compiler.visitNode (/home/rohan/.meteorite/packages/jade-handlebars/jrhone/meteor-jade-handlebars/e442fecedeac64b81a0865e1b195a630181a3ee4/jade/lib/compiler.js:176:32)
at Object.Compiler.visit (/home/rohan/.meteorite/packages/jade-handlebars/jrhone/meteor-jade-handlebars/e442fecedeac64b81a0865e1b195a630181a3ee4/jade/lib/compiler.js:161:10)
Thank You in advance!!!!!
Even if you could get this to compile, I'm not sure it will do anything because of the way meteor dynamically injects elements into the body. For example if you add:
script(type='text/javascript') alert('hello!')
to your jade, or the equivalent:
<script type="text/javascript">alert('hello!')</script>
to your html, it won't actually execute - at least it doesn't for me. I think this is because the body has already rendered before the script was injected onto the page.
That aside, I did get this to compile, but not using jade-handlebars. See my answer here.
Related
I would like to require the webpack.config in karma.conf to reduce duplication. Somehow it is not working and some errors are being thrown.
Module not found: Error: a dependency to an entry point is not allowed
ERROR [karma]: Uncaught ReferenceError: webpackJsonp is not defined
the way webpack.config is required in karma.conf
var webpackConfig = require('./webpack.config');
webpackConfig.devtool = 'inline-source-map';
webpackConfig.plugins.push(new RewirePlugin());
The entry and output property of the webpack.config are not needed in karma.conf, that might be messing with the setup. How can I get rid of it?
I have tried: webpackConfig.entry = {}; which didn't succeed.
The problem could also be something else?
Would be very nice if you could point to an existing example or correct my mistake!
I'm having some troubles understanding, what i believe is trivial but i can't seem to get my head around it.
I have this publish function in server.js (server only)
Meteor.publish("tikiMainFind", function(){
return tikiDB.find()
})
In app.js (server + client) i'm declaring this mongo collection:
tikiDB = new Mongo.Collection("tiki")
Why is it that this doesn't work in client.js
console.log(tikiDB.find())
//ReferenceError: tikiDB is not defined
Without any idea how you have your app structured, I agree with David Weldon's answer. Check File Load Order to see what order your files are getting loaded.
I am trying to migrate a project from 0.9.9 to 0.10.5
We were using dust templating engine in our porject instead of the default ejs engine.
Contents of config/views.js file
module.exports.views = {
engine: 'dust',
layout: 'layout'
};
In my controller, I was able to render this view like this
res.view('layout', obj);
However, in sails 0.10.5, when I lift sails, first of all I get this warning
warn: Sails' built-in layout support only works with the `ejs` view engine.
warn: You're using `dust`.
warn: Ignoring `sails.config.views.layout`...
And then when I try to render the view as I was doing earlier, I get following error:
error: Sending 500 ("Server Error") response:
Error: ENOENT, open '/.dust'
{ [Error: ENOENT, open '/.dust'] errno: 34, code: 'ENOENT', path: '/.dust' }
Any idea what is the correct way of doing this in 0.10.5 ?
The layout property does not apply to dust (just ejs). Set layout to false to get the warning to go away. You want to use Dust's built-in support for partials and blocks anyways.
Using res.view('layout', obj); means that you expect a file called views/layout.dust to exist. Prior to 0.10, sails was including the layout property from config/views.js as part of the path.
So my best guess is that your res.view() call is actually being invoked with an empty string as the first parameter, and it wasn't breaking because you were trying to render something called layout. I'd check your invocation to make sure that you're calling res.view() with an instantiated variable.
I am having trouble getting my handlebars templates accessible in rails 3.1. I have the following controller:
Lead.Controllers.UrlSearch = Ember.Object.extend
init: ->
view = Ember.View.create
controller: #
urlSearchBinding: 'controller.url_search'
templateName: 'app/templates/url_search/show'
On the rails side of things, I have a the following initialisation script in config/initializers/sprockets.rb
require 'sprockets/ember_handlebars'
Rails.application.assets.register_engine 'hjs', EmberHandlebars
My EmberHandleBars looks like this:
require 'tilt'
require 'json'
class EmberHandlebars < Tilt::Template
def self.default_mime_type
"application/javascript"
end
def prepare
end
def evaluate(scope, locals, &block)
"Ember.TEMPLATES['#{scope.logical_path}'] = Ember.Handlebars.compile(#{data.to_json})"
end
end
Finally, the template is located in:
app/assets/javascripts/app/templates/url_search/show.jst.hjs
In there error console, I get this 404 resource error:
GET
http://localhost:3000/assets/app/templates/url_search/show.hjs.js?body=1
404 (Not Found)
and also
Error: - Unable to find template
"app/templates/url_search/show".
I am confused why it is looking for an hjs.js file when I have specified otherwise and why it cannot find the template.
Can anyone see what I am doing wrong?
Changing the file extensions form .jst.hjs to just .hjs fixed the problem.
I'm currently working on a Rails plugin used for generating iPhone specific HTML meta-tags. I'm trying to use ActionView::TestCase for unit tests but keep getting the same error. See file contents and error below. Any ideas or help would be much appreciated.
test_helper.rb
require 'rubygems'
require 'test/unit'
require 'active_support'
require 'action_view'
require File.join(File.dirname(__FILE__), '..', 'lib', 'iphone_helper')
iphone_test_helper.rb
require 'test_helper'
class IphoneHelperTest < ActionView::TestCase
test 'br' do
tag = tag('br')
assert_tag_in tag, '<br />'
end
end
error
RuntimeError: In order to use #url_for, you must include routing helpers explicitly. For instance, `include Rails.application.routes.url_helpers
Awful and hacky workaround that worked for me (since I am working on a gem and not in a full rails environment):
require 'ostruct'
module ActionController::UrlFor
def _routes
helpers = OpenStruct.new
helpers.url_helpers = Module.new
helpers
end
end
Did you try to include the respective Module in an old-fashioned way?:
include ActionDispatch::Routing::RouteSet
If a NameError is raised telling you that ActionDispatch is unknown you might have to require 'action_dispatch'.
Maybe a stupid question, but is the fact that the class name and the file name don't match possibly a problem (IphoneHelperTest vs. iphone_test_helper.rb)? Sometimes that leads to classes not being loaded.