edmellum / browserijade Goto Github PK
View Code? Open in Web Editor NEWA Browserify middleware that pre-compiles Jade templates on the server and uses the light-weight Jade runtime made for the browser to render them on the client.
A Browserify middleware that pre-compiles Jade templates on the server and uses the light-weight Jade runtime made for the browser to render them on the client.
I'm seeing a problem where require('jade/runtime') returns an empty object. This causes an 'undefined not a function' error when the runtime is used. I have a working fix at loku/browserijade@c1b6fa0, but I don't really understand what's going on here.
I stepped through it some, and it seems like require('jade/runtime') tries to require '/node_modules/jade/lib/runtime.js'. I don't know why this would return an empty object, though.
Does it work for you? What version of browserify are you using? I'm on 1.10.11 now.
Note I had to do the runtimePath
trickery to get browserify not to die before the browserijade middleware even runs, since at that time 'jade-runtime' is not available.
In the readme, an example says :
bundle.use(browserijade(__dirname + "/views"), ['serverThing.jade'], {debug: true})
I think it should say :
bundle.use(browserijade(__dirname + "/views", ['serverThing.jade'], {debug: true}))
In Express you can define global locals using app.locals
. Jade templates that run on Express on the server-side that use these globally defined locals work just fine. However, they do not work on the client-side; I just get error messages saying that the locals are not defined. Is there a way to get app.locals to work on the client-side, or is there a way to define a separate set of locals for browserijade?
if pin.blog
.blog
section
a(href='/blog/#{pin.blog.blogId}')
h1= pin.blog.title
.body!= pin.blog.excerpt
if (pin.bodyHTML)
.body!= pin.bodyHTML
both of the .body elements get the same content which is pin.bodyHTML + pin.blog.excerpt
. This is an error. If I change one of the element's class name, to say, .blog-body, then each element has different content as it should.
What's going on here? Is this browserijade's fault/error?
E.g. src/browser.coffee
and src/server.coffee
are missing. I will be forking to fix #2, and to provide partial
support in the client.
In the meantime I will just commit this stuff in my fork.
Also, the packaged version of src/middleware.coffee
contains a hardcoded path /home/vagrant/edmellum/lib/shared
, while this is missing from lib/middleware.js
. I would suggest removing the compiled js files from version control (and gitignoring them).
If lib/runtime.js is not included in the package, browserify will die with an error before there is an opportunity to cacheRuntime.
So it seems that cacheRuntime is pointless in the middleware and should be moved to the build?
I seem to be running into a Safari exception with my project. I'm having trouble pin-pointing exactly where the exception is coming from, but it appears to be in my browserify bundle and specifically a browserijade template. I'm wondering if it could possibly be something wrong in my jade template or in browserijade itself (it's hard to tell because jade templates are literally compiled down to one line of code, so it's beyond me as to how to debug this issue).
If it were my jade template, then I would see this exception not exclusively in Safari. The exception, specifically, is SyntaxError: Expected token ')'
.
Maybe there's a way to turn on a debugging mode for browserijade, so that the templates aren't compiled down to one line of code. This would give me better debugging information for the exception.
However, the question remains, how much testing has been put into this library? What browsers and versions have been tested?
Error: Cannot find module "[...]/views/partials" from directory "[...]/views"
at Function. ([...]/node_modules/browserify/lib/wrap.js:379:19)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.