Skip to content

Commit

Permalink
Merge pull request #97 from jonschlinkert/master
Browse files Browse the repository at this point in the history
new "relative" helper for resolving paths
  • Loading branch information
jonschlinkert committed Mar 18, 2013
2 parents 351c32e + 7f610e8 commit d02af19
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 58 deletions.
51 changes: 26 additions & 25 deletions Gruntfile.js
Expand Up @@ -11,6 +11,7 @@ module.exports = function(grunt) {


// Project configuration. // Project configuration.
grunt.initConfig({ grunt.initConfig({

// package.json // package.json
pkg: grunt.file.readJSON('package.json'), pkg: grunt.file.readJSON('package.json'),
meta: { meta: {
Expand All @@ -20,19 +21,19 @@ module.exports = function(grunt) {
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */' ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
}, },

jshint: { jshint: {
options: {
jshintrc: '.jshintrc'
},
files: [ files: [
'Gruntfile.js', 'Gruntfile.js',
'lib/**/*.js', 'lib/**/*.js',
'tasks/**/*.js', 'tasks/**/*.js',
'test/**/*.js' 'test/**/*.js'
], ]
options: {
jshintrc: '.jshintrc'
}
}, },
// Run tests.
// Run mocha tests.
mochaTest: { mochaTest: {
files: ['test/**/*.js'] files: ['test/**/*.js']
}, },
Expand All @@ -42,26 +43,8 @@ module.exports = function(grunt) {
} }
}, },


// Run simple tests.
assemble: { assemble: {
// Internal task to build README, docs. // Run basic tests on templates and data.
readme: {
options: {
today: '<%= grunt.template.today() %>',
partials: ['docs/*.md','docs/templates/sections/*.{md,hbs}'],
changelog: grunt.file.readYAML('CHANGELOG'),
roadmap: grunt.file.readYAML('ROADMAP'),
data: [
'docs/templates/data/docs.json',
'../assemble-internal/docs/templates/data/url.json',
'../assemble-internal/docs/templates/data/repos.json'
],
ext: '.md'
},
files: {
'.': ['../assemble-internal/docs/templates/README.hbs']
}
},
tests: { tests: {
options: { options: {
layout: 'test/files/layout-includes.hbs' layout: 'test/files/layout-includes.hbs'
Expand All @@ -77,6 +60,24 @@ module.exports = function(grunt) {
files: { files: {
'test/actual/yaml': ['test/yaml/*.hbs'] 'test/actual/yaml': ['test/yaml/*.hbs']
} }
},
// Internal task to build README, docs.
readme: {
options: {
today: '<%= grunt.template.today() %>',
partials: ['docs/*.md','docs/templates/sections/*.{md,hbs}'],
changelog: grunt.file.readYAML('CHANGELOG'),
roadmap: grunt.file.readYAML('ROADMAP'),
ext: '.md',
data: [
'docs/templates/data/docs.json',
'../assemble-internal/docs/templates/data/url.json',
'../assemble-internal/docs/templates/data/repos.json'
]
},
files: {
'.': ['../assemble-internal/docs/templates/README.hbs']
}
} }
} }
}); });
Expand Down
4 changes: 1 addition & 3 deletions README.md
Expand Up @@ -37,8 +37,6 @@ _This project just launched **so expect frequent changes** for the near future,








## Quick start ## Quick start
This plugin requires Grunt `~0.4.0` This plugin requires Grunt `~0.4.0`


Expand Down Expand Up @@ -638,7 +636,7 @@ Copyright 2013 Assemble


--- ---


_This file was generated with Grunt and [assemble](http://github.com/assemble/assemble) on Sat Mar 16 2013 16:47:56._ _This file was generated with Grunt and [assemble](http://github.com/assemble/assemble) on Mon Mar 18 2013 00:51:12._






Expand Down
2 changes: 1 addition & 1 deletion component.json
@@ -1,6 +1,6 @@
{ {
"name": "assemble", "name": "assemble",
"version": "0.3.12", "version": "0.3.14",
"main": [ "main": [
"./lib/assemble.js" "./lib/assemble.js"
], ],
Expand Down
5 changes: 3 additions & 2 deletions docs/toc.md
@@ -1,3 +1,5 @@


**Table of Contents** **Table of Contents**


- [The "assemble" task](#the-assemble-task) - [The "assemble" task](#the-assemble-task)
Expand Down Expand Up @@ -25,5 +27,4 @@
- [Bug tracker](#bug-tracker) - [Bug tracker](#bug-tracker)
- [Contributing](#contributing) - [Contributing](#contributing)
- [Authors](#authors) - [Authors](#authors)
- [License](#copyright-and-license) - [License](#copyright-and-license)

2 changes: 1 addition & 1 deletion lib/assemble.js
Expand Up @@ -4,7 +4,7 @@
* Assemble * Assemble
* http://assemble.io * http://assemble.io
* *
* Copyright (c) 2012 Upside * Copyright (c) 2012 Upstage
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT * https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */ * ========================================================== */
Expand Down
49 changes: 34 additions & 15 deletions lib/engines/handlebars/helpers/defaultHelpers.js
Expand Up @@ -9,8 +9,7 @@ if(!define || typeof define !== 'function') {
* be used inside your handlebars templates * be used inside your handlebars templates
*/ */


define([], define([], function() {
function() {


// figure out if this is node or browser // figure out if this is node or browser
var isServer = (typeof process !== 'undefined'); var isServer = (typeof process !== 'undefined');
Expand All @@ -22,10 +21,14 @@ function() {
Utils = {}, Utils = {},
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) { return i; } } return -1; }; __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) { return i; } } return -1; };


// if(isServer) { // if(isServer) {
var assemble = require('../../../assemble.js'), var assemble = require('../../../assemble.js');
markdown = assemble.Markdown({gfm: true, highlight: 'auto'}); var fs = require('fs');
// } var util = require('util');
var path = require('path');
var dest = './';
var markdown = assemble.Markdown({gfm: true, highlight: 'auto'});
// }




/************************************************************* /*************************************************************
Expand All @@ -47,6 +50,12 @@ function() {
return str.toString().replace(trim, ''); return str.toString().replace(trim, '');
}; };


// Normalize slashes in URLs
Utils.urlNormalize = function(urlString) {
return urlString.replace(/\\/g, '/');
};




/************************************************************* /*************************************************************
* HTML * HTML
Expand Down Expand Up @@ -362,7 +371,7 @@ function() {


/** /**
* Dashify * Dashify
* Replace dots in string with hyphens. * Replace periods in string with hyphens.
*/ */
Handlebars.registerHelper('dashify', function(tag) { Handlebars.registerHelper('dashify', function(tag) {
return tag.split('.').join('-'); return tag.split('.').join('-');
Expand Down Expand Up @@ -481,14 +490,6 @@ function() {
return "" + space + str + space; return "" + space + str + space;
}); });


/**
* newLineToBr
* Converts new line characters `\n` to line breaks `<br>`.
*/
Handlebars.registerHelper('newLineToBr', function(str) {
return str.replace(/\n/g, '<br>');
});



// ========================================================== // ==========================================================
// //
Expand Down Expand Up @@ -734,6 +735,24 @@ function() {
return ret; return ret;
}); });


/**
* Relative path
* Returns the derived relative path from one to the other.
*/
Handlebars.registerHelper('relative', function(from, to) {

var relativePath = path.relative(from, to);

if(relativePath === "." || relativePath.length === 0) {
relativePath = dest;
}
relativePath = Utils.urlNormalize(path.relative(
path.resolve(path.join(dest, relative)),
path.resolve(relativePath)
));
return relativePath;
});

/** /**
* Add * Add
* Returns the sum of two numbers. * Returns the sum of two numbers.
Expand Down
Expand Up @@ -4,7 +4,7 @@
* Assemble * Assemble
* http://assemble.io * http://assemble.io
* *
* Copyright (c) 2012 Upside * Copyright (c) 2012 Upstage
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT * https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */ * ========================================================== */
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/common-preprocessors.js
Expand Up @@ -2,7 +2,7 @@
* Assemble * Assemble
* http://assemble.io * http://assemble.io
* *
* Copyright (c) 2012 Upside * Copyright (c) 2012 Upstage
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT * https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */ * ========================================================== */
Expand Down
10 changes: 5 additions & 5 deletions lib/utils/engineLoader.js
Expand Up @@ -4,17 +4,17 @@
* Assemble * Assemble
* http://assemble.io * http://assemble.io
* *
* Copyright (c) 2012 Upside * Copyright (c) 2012 Upstage
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT * https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */ * ========================================================== */


(function(exports) { (function(exports) {


var fs = require('fs'), var fs = require('fs'),
path = require('path'), path = require('path'),
_ = require('lodash'), _ = require('lodash'),
extensions = require('../config/extensionMap'), extensions = require('../config/extensionMap'),
commonPreprocessor = require('./common-preprocessors'); commonPreprocessor = require('./common-preprocessors');


var EngineLoader = function(options) { var EngineLoader = function(options) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/frontMatter.js
Expand Up @@ -4,7 +4,7 @@
* Assemble * Assemble
* http://assemble.io * http://assemble.io
* *
* Copyright (c) 2012 Upside * Copyright (c) 2012 Upstage
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT * https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */ * ========================================================== */
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/index.js
Expand Up @@ -4,7 +4,7 @@
* Assemble * Assemble
* http://assemble.io * http://assemble.io
* *
* Copyright (c) 2012 Upside * Copyright (c) 2012 Upstage
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT * https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */ * ========================================================== */
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/markdown.js
Expand Up @@ -4,7 +4,7 @@
* Assemble * Assemble
* http://assemble.io * http://assemble.io
* *
* Copyright (c) 2012 Upside * Copyright (c) 2012 Upstage
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT * https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */ * ========================================================== */
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{ {
"name": "assemble", "name": "assemble",
"description": "Get the rocks out of your socks. Assemble helps you **quickly launch static web projects** by emphasizing a strong separation of concerns between structure, style, content and configuration.", "description": "Get the rocks out of your socks. Assemble helps you **quickly launch static web projects** by emphasizing a strong separation of concerns between structure, style, content and configuration.",
"version": "0.3.13", "version": "0.3.14",
"homepage": "https://github.com/assemble/assemble", "homepage": "https://github.com/assemble/assemble",
"author": { "author": {
"name": "assemble", "name": "assemble",
Expand Down

0 comments on commit d02af19

Please sign in to comment.