Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

new "relative" helper for resolving paths #97

Merged
merged 3 commits into from

1 participant

This page is out of date. Refresh to see the latest.
View
51 Gruntfile.js
@@ -11,6 +11,7 @@ module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
+
// package.json
pkg: grunt.file.readJSON('package.json'),
meta: {
@@ -20,19 +21,19 @@ module.exports = function(grunt) {
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
-
jshint: {
+ options: {
+ jshintrc: '.jshintrc'
+ },
files: [
'Gruntfile.js',
'lib/**/*.js',
'tasks/**/*.js',
'test/**/*.js'
- ],
- options: {
- jshintrc: '.jshintrc'
- }
+ ]
},
- // Run tests.
+
+ // Run mocha tests.
mochaTest: {
files: ['test/**/*.js']
},
@@ -42,26 +43,8 @@ module.exports = function(grunt) {
}
},
- // Run simple tests.
assemble: {
- // 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'),
- 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']
- }
- },
+ // Run basic tests on templates and data.
tests: {
options: {
layout: 'test/files/layout-includes.hbs'
@@ -77,6 +60,24 @@ module.exports = function(grunt) {
files: {
'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']
+ }
}
}
});
View
4 README.md
@@ -37,8 +37,6 @@ _This project just launched **so expect frequent changes** for the near future,
-
-
## Quick start
This plugin requires Grunt `~0.4.0`
@@ -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._
View
2  component.json
@@ -1,6 +1,6 @@
{
"name": "assemble",
- "version": "0.3.12",
+ "version": "0.3.14",
"main": [
"./lib/assemble.js"
],
View
5 docs/toc.md
@@ -1,3 +1,5 @@
+
+
**Table of Contents**
- [The "assemble" task](#the-assemble-task)
@@ -25,5 +27,4 @@
- [Bug tracker](#bug-tracker)
- [Contributing](#contributing)
- [Authors](#authors)
-- [License](#copyright-and-license)
-
+- [License](#copyright-and-license)
View
2  lib/assemble.js
@@ -4,7 +4,7 @@
* Assemble
* http://assemble.io
*
- * Copyright (c) 2012 Upside
+ * Copyright (c) 2012 Upstage
* Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */
View
49 lib/engines/handlebars/helpers/defaultHelpers.js
@@ -9,8 +9,7 @@ if(!define || typeof define !== 'function') {
* be used inside your handlebars templates
*/
-define([],
-function() {
+define([], function() {
// figure out if this is node or browser
var isServer = (typeof process !== 'undefined');
@@ -22,10 +21,14 @@ function() {
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; };
-// if(isServer) {
- var assemble = require('../../../assemble.js'),
- markdown = assemble.Markdown({gfm: true, highlight: 'auto'});
-// }
+ // if(isServer) {
+ var assemble = require('../../../assemble.js');
+ var fs = require('fs');
+ var util = require('util');
+ var path = require('path');
+ var dest = './';
+ var markdown = assemble.Markdown({gfm: true, highlight: 'auto'});
+ // }
/*************************************************************
@@ -47,6 +50,12 @@ function() {
return str.toString().replace(trim, '');
};
+ // Normalize slashes in URLs
+ Utils.urlNormalize = function(urlString) {
+ return urlString.replace(/\\/g, '/');
+ };
+
+
/*************************************************************
* HTML
@@ -362,7 +371,7 @@ function() {
/**
* Dashify
- * Replace dots in string with hyphens.
+ * Replace periods in string with hyphens.
*/
Handlebars.registerHelper('dashify', function(tag) {
return tag.split('.').join('-');
@@ -481,14 +490,6 @@ function() {
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>');
- });
-
// ==========================================================
//
@@ -735,6 +736,24 @@ function() {
});
/**
+ * 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
* Returns the sum of two numbers.
*/
View
2  lib/engines/handlebars/preprocessors/handlebarsPreprocessors.js
@@ -4,7 +4,7 @@
* Assemble
* http://assemble.io
*
- * Copyright (c) 2012 Upside
+ * Copyright (c) 2012 Upstage
* Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */
View
2  lib/utils/common-preprocessors.js
@@ -2,7 +2,7 @@
* Assemble
* http://assemble.io
*
- * Copyright (c) 2012 Upside
+ * Copyright (c) 2012 Upstage
* Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */
View
10 lib/utils/engineLoader.js
@@ -4,17 +4,17 @@
* Assemble
* http://assemble.io
*
- * Copyright (c) 2012 Upside
+ * Copyright (c) 2012 Upstage
* Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */
(function(exports) {
- var fs = require('fs'),
- path = require('path'),
- _ = require('lodash'),
- extensions = require('../config/extensionMap'),
+ var fs = require('fs'),
+ path = require('path'),
+ _ = require('lodash'),
+ extensions = require('../config/extensionMap'),
commonPreprocessor = require('./common-preprocessors');
var EngineLoader = function(options) {
View
2  lib/utils/frontMatter.js
@@ -4,7 +4,7 @@
* Assemble
* http://assemble.io
*
- * Copyright (c) 2012 Upside
+ * Copyright (c) 2012 Upstage
* Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */
View
2  lib/utils/index.js
@@ -4,7 +4,7 @@
* Assemble
* http://assemble.io
*
- * Copyright (c) 2012 Upside
+ * Copyright (c) 2012 Upstage
* Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */
View
2  lib/utils/markdown.js
@@ -4,7 +4,7 @@
* Assemble
* http://assemble.io
*
- * Copyright (c) 2012 Upside
+ * Copyright (c) 2012 Upstage
* Licensed under the MIT license.
* https://github.com/assemble/assemble/blob/master/LICENSE-MIT
* ========================================================== */
View
2  package.json
@@ -1,7 +1,7 @@
{
"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.",
- "version": "0.3.13",
+ "version": "0.3.14",
"homepage": "https://github.com/assemble/assemble",
"author": {
"name": "assemble",
Something went wrong with that request. Please try again.