Permalink
Browse files

Push to 3.2.2

Moved Meteor smart package to another repository (https://github.com/bminer/meteor-blade)
Removed postinstall script entirely
  • Loading branch information...
bminer committed Apr 8, 2013
1 parent 1614b22 commit 7a966867ad27b0bd9d353c072d4c21d86f773625
Showing with 6 additions and 209 deletions.
  1. +4 −1 lib/blade.js
  2. +0 −18 meteor/helpers-hack.js
  3. +0 −104 meteor/package.js
  4. +0 −63 meteor/runtime-meteor.js
  5. +0 −1 meteor/runtime.js
  6. +0 −10 meteor/smart.json
  7. +2 −3 package.json
  8. +0 −9 postinstall.js
View
@@ -20,6 +20,9 @@ exports.compileFile = compileFile;
exports.Compiler = Compiler;
exports.renderFile = exports.__express = renderFile;
exports.middleware = middleware;
+exports.readRuntime = function() {
+ return fs.readFileSync(__dirname + "/runtime.js");
+}
//Cache of compiled template functions
var cache = {};
@@ -128,7 +131,7 @@ function middleware(sourcePath, options) {
if(fileCache["runtime"])
res.type("application/javascript").send(fileCache["runtime"]);
else
- fs.readFile(__dirname + "/../lib/runtime.js", function(err, data) {
+ fs.readFile(__dirname + "/runtime.js", function(err, data) {
if(err) return next(err);
data = bladeutil.uglify(data.toString(), true);
fileCache["runtime"] = data;
View
@@ -1,18 +0,0 @@
-//This is a horrible hack that will hopefully be corrected.
-Meteor.startup(function() {
- _.each(Meteor._partials, function(partial, partialName) {
- _.each(Handlebars._default_helpers, function(helper, helperName) {
- //Expose other Handlebars helpers to Blade
- if(helperName != "constant" &&
- helperName != "each" &&
- helperName != "if" &&
- helperName != "isolate" &&
- helperName != "unless" &&
- helperName != "with"
- )
- partial[helperName] = function() {
- return helper({"hash": {} });
- };
- });
- });
-});
View
@@ -1,104 +0,0 @@
-Package.describe({
- summary: "Blade - HTML Template Compiler, inspired by Jade & Haml"
-});
-
-Npm.depends({"blade": ">=3"});
-
-Package.register_extension("blade", function(bundle, srcPath, servePath, where) {
- var path = Npm.require("path"),
- blade = Npm.require("blade");
- if(where !== "client") return; //get outta here, yo!
- //The template name does not contain ".blade" file extension or a beginning "/"
- var templateName = path.dirname(servePath).substr(1);
- templateName += (templateName.length > 0 ? "/" : "") + path.basename(servePath, ".blade");
- //Templates are assumed to be stored in "views/" or "client/views/"
- //so remove this from the name, if needed
- if(templateName.substr(0, 6) == "views/")
- templateName = templateName.substr(6);
- else if(templateName.substr(0, 13) == "client/views/")
- templateName = templateName.substr(13);
- //Remove directory prefix if not in views/ or client/views/
- else
- templateName = templateName.substr(templateName.lastIndexOf("/") + 1);
- //Finally, tell the Blade compiler where these views are stored, so that file includes work.
- //The location of meteor project = srcPath.substr(0, srcPath.length - servePath.length)
- var basedir = srcPath.substr(0, srcPath.length - servePath.length);
- blade.compileFile(srcPath, {
- 'synchronous': true,
- 'basedir': basedir,
- 'cache': false, //disabled because we only compile each file once anyway
- 'minify': false, //would be nice to have access to `no_minify` bundler option
- 'includeSource': true //default to true for debugging
- }, function(err, tmpl) {
- if(err) throw err;
- if(templateName == "head")
- tmpl({}, function(err, html) {
- //This should happen synchronously due to compile options set above
- if(err) throw err;
- bundle.add_resource({
- type: templateName,
- data: html,
- where: where
- });
- });
- else
- {
- var data = "blade._cachedViews[" +
- //just put the template itself in blade._cachedViews
- JSON.stringify(templateName + ".blade") + "]=" + tmpl.toString() + ";" +
- //define a template with the proper name
- "Meteor._def_template(" + JSON.stringify(templateName) +
- //when the template is called...
- ", function(data, obj) {data = data || {};" +
- //helpers work... even functions, thanks to Object.defineProperty!
- "for(var i in obj.helpers){" +
- "if(typeof obj.helpers[i] != 'function' || !Object.defineProperty)\n" +
- "data[i]=obj.helpers[i];\n" +
- "else\n" +
- "Object.defineProperty(data,i,{" +
- "get:obj.helpers[i],configurable:true,enumerable:true" +
- "});" +
- "}" +
- //Get `info` Object from the parent template (if any) and its length
- "var info = blade._includeInfo || [], startLen = info.length;" +
- //Expose `partials`
- "info.partials = obj.partials;" +
- /*call the actual Blade template here, passing in data
- `ret` is used to capture async results.
- Note that since we are using caching for file includes,
- there is no async. All code is ran synchronously. */
- "var ret = ''; blade._cachedViews[" + JSON.stringify(templateName + ".blade") +
- "](data, function(err,html,info) {" +
- "if(err) throw err;" +
- "html = info.slice(startLen).join('');" +
- //Remove event handler attributes
- 'html = html.replace(/on[a-z]+\\=\\"return blade\\.Runtime\\.trigger\\(this\\,arguments\\)\\;\\"/g, "");' +
- //now bind any inline events and return
- "ret = blade.LiveUpdate.attachEvents(info.eventHandlers, html);" +
- "},info);\n" +
- //so... by here, we can just return `ret`, and everything works okay
- "return ret;" +
- "}" +
- ");";
- if(templateName == "body")
- data += "Meteor.startup(function(){" +
- "document.body.appendChild(Spark.render(Template.body));" +
- "});"
- bundle.add_resource({
- type: 'js',
- path: "/views/" + templateName + ".js", //This can be changed to whatever
- data: data,
- where: where
- });
- }
- });
-});
-
-Package.on_use(function(api) {
- //The plain-old Blade runtime
- api.add_files('runtime.js', 'client');
- //The Blade runtime with overridden loadTemplate function, designed for Meteor
- api.add_files('runtime-meteor.js', 'client');
- //A hack to get Handlebars helpers to work with Blade
- api.add_files('helpers-hack.js', 'client');
-});
View
@@ -1,63 +0,0 @@
-(function() {
- //Helper function
- function resolveFilename(filename) {
- //Append .blade for filenames without an extension
- if(filename.split("/").pop().indexOf(".") < 0)
- filename += ".blade";
- return blade.Runtime.resolve(filename);
- }
- //Overwrite blade.Runtime.loadTemplate and include functions
- blade.Runtime.loadTemplate = function(baseDir, filename, compileOptions, cb) {
- filename = resolveFilename(filename);
- //Either pull from the cache or return an error
- if(blade._cachedViews[filename])
- {
- cb(null, blade._cachedViews[filename]);
- return true;
- }
- cb(new Error("Template '" + filename + "' could not be loaded.") );
- return false;
- };
- var oldInclude = blade.Runtime.include;
- blade.Runtime.include = function(relFilename, info) {
- //Save old info
- var oldIncludeInfo = blade._includeInfo,
- old = blade.Runtime._beforeInclude.apply(this, arguments),
- bufLength = info.length,
- branchLabel = info.filename + ":" + info.line + ":inc:" + relFilename;
- //expose `info` to the raw_func generated by `package.js`
- blade._includeInfo = info;
- //Get the name of the included Template
- var name = resolveFilename(info.rel + "/" + relFilename);
- //Remove views/ or client/views/ prefix
- if(name.substr(0, 6) == "views/")
- name = name.substr(6);
- else if(name.substr(0, 13) == "client/views/")
- name = name.substr(13);
- //Remove directory prefix if not in views/ or client/views/
- else
- name = name.substr(name.lastIndexOf("/") + 1);
- //Remove .blade file extension
- if(name.substr(-6) == ".blade")
- name = name.substr(0, name.length - 6);
- //Render the child template to get the reactive HTML (and to populate `info`)
- var reactiveHTML = Spark.labelBranch(branchLabel, function() {
- return info.partials[name](info.locals);
- });
- //If no block definitions were found in the parent and child templates, we can use the reactive HTML
- if(!info.bd)
- {
- //Remove non-reactive HTML
- blade.Runtime.capture(info, bufLength);
- //Add reactive HTML
- info.push(reactiveHTML);
- }
- //else... just use whatever is in `info` (non-reactive HTML)
- blade._includeInfo = oldIncludeInfo;
- blade.Runtime._afterInclude(old, info);
- };
-
- //Use Spark as the live update engine
- for(var i in Spark)
- blade.LiveUpdate[i] = Spark[i];
-})();
View
View
@@ -1,10 +0,0 @@
-{
- "name": "blade",
- "author": "Blake Miner <miner.blake@gmail.com> (http://www.blakeminer.com/)",
- "description": "Blade - HTML Template Compiler, inspired by Jade & Haml",
- "homepage": "https://github.com/bminer/node-blade",
- "version": "3.2.1",
- "git": "https://github.com/bminer/node-blade.git",
- "packages": {
- }
-}
View
@@ -15,7 +15,7 @@
"live binding",
"meteor"
],
- "version": "3.2.1",
+ "version": "3.2.2",
"homepage": "https://github.com/bminer/node-blade",
"repository": {
"type": "git",
@@ -40,8 +40,7 @@
"scripts": {
"pretest": "./lib/parser/build.sh",
"test": "node ./test/test.js",
- "prepublish": "./lib/parser/build.sh",
- "postinstall": "node ./postinstall.js"
+ "prepublish": "./lib/parser/build.sh"
},
"contributors": [
"Michel Löhr (https://github.com/mlohr)"
View
@@ -1,9 +0,0 @@
-/* Installs symlinks in ./meteor smart package directory since Meteor does not ship
-with Blade just yet...
-I'm hoping that I can get rid of this script someday... */
-var fs = require('fs');
-if(!fs.existsSync)
- fs.existsSync = require('path').existsSync; //Node 0.6 compatibility
-//bash: [ -h ./meteor/runtime.js ] || ln -s ../lib/runtime.js ./meteor/runtime.js
-if(!fs.existsSync("./meteor/runtime.js") )
- fs.symlink("../lib/runtime.js", "./meteor/runtime.js");

0 comments on commit 7a96686

Please sign in to comment.