Additional renames to Marko

This commit is contained in:
Patrick Steele-Idem 2014-09-19 07:22:03 -06:00
parent 2db28d398b
commit 55b559f981
9 changed files with 43 additions and 43 deletions

View File

@ -73,7 +73,7 @@ Marko is an extensible, streaming, asynchronous, [high performance](https://gith
Most front-end developers are familiar with, and comfortable with, templating languages such as [Handlebars](https://github.com/wycats/handlebars.js), [Dust](https://github.com/linkedin/dustjs) or [Mustache](http://mustache.github.io/) so why was Marko introduced?
What makes Marko different is that it is an HTML-based templating language that does not rely on a custom language grammar. Any HTML file is a valid Raptor Template and vice-versa, and the Marko compiler uses an [off-the-shelf HTML parser](https://github.com/fb55/htmlparser2). Because Marko understands the HTML structure of the templates, it can do more powerful things that would not be possible in a text-based templating languages such as Handlerbars, Dust or Mustache. Marko allows developers to _extend the HTML language_ by introducing custom HTML elements and attributes. On top of that, utilizing the HTML structure for applying templating directives makes templates more readable and allows input templates to more closely resemble the final HTML structure.
What makes Marko different is that it is an HTML-based templating language that does not rely on a custom language grammar. Any HTML file is a valid Marko template and vice-versa, and the Marko compiler uses an [off-the-shelf HTML parser](https://github.com/fb55/htmlparser2). Because Marko understands the HTML structure of the templates, it can do more powerful things that would not be possible in a text-based templating languages such as Handlerbars, Dust or Mustache. Marko allows developers to _extend the HTML language_ by introducing custom HTML elements and attributes. On top of that, utilizing the HTML structure for applying templating directives makes templates more readable and allows input templates to more closely resemble the final HTML structure.
Let's compare Marko with Handlebars (a text-based templating language):
@ -120,7 +120,7 @@ A few things to note for the Marko template:
Beyond Marko being an HTML-based templating language, it was also designed with extreme performance and extensibility in mind. The Marko compiler gives developers full control over how templates are compiled to JavaScript and the runtime was designed to be as efficient as possible. Marko fully embraces the JavaScript language for better performance and flexibility (e.g. favoring JavaScript expressions over a custom expression language).
Finally, another distinguishing feature of Marko is that it supports _asynchronous template rendering_. This powerful feature allows portions of the template to be rendered asynchronously. Instead of waiting for all data to come back from remote services before beginning to render the template, you can now immediately start rendering the template and the portions of the template that depend on asynchronous data will render as soon as the asynchronous data becomes available. The Raptor Template rendering engine ensures that the final HTML will be streamed out in the correct order.
Finally, another distinguishing feature of Marko is that it supports _asynchronous template rendering_. This powerful feature allows portions of the template to be rendered asynchronously. Instead of waiting for all data to come back from remote services before beginning to render the template, you can now immediately start rendering the template and the portions of the template that depend on asynchronous data will render as soon as the asynchronous data becomes available. The Marko rendering engine ensures that the final HTML will be streamed out in the correct order.
# Design Philosophy
@ -338,12 +338,12 @@ console.log('Output HTML: ' + output);
### Asynchronous Render Context API
```javascript
var raptorTemplates = require('marko');
var template = raptorTemplates.load('template.marko');
var marko = require('marko');
var template = marko.load('template.marko');
var out = require('fs').createWriteStream('index.html', 'utf8');
var context = raptorTemplates.createContext(out);
var context = marko.createContext(out);
// Render the first chunk asynchronously (after 1s delay):
var asyncContext = context.beginAsync();
@ -396,7 +396,7 @@ You can then bundle up the above program for running in the browser using either
### Using the RaptorJS Optimizer
The `optimizer` CLI can be used to generate resource bundles that includes all application modules and all referenced Raptor Template files using a command similar to the following:
The `optimizer` CLI can be used to generate resource bundles that includes all application modules and all referenced Marko template files using a command similar to the following:
```bash
# First install the optimizer and the optimizer-marko plugin
npm install optimizer --global
@ -416,7 +416,7 @@ optimizer --main run.js --name my-page --plugins optimizer-marko --inject-into m
### Using Browserify
The `markoify` transform for browserify must be enabled in order to automatically compile and include referenced Raptor Template files.
The `markoify` transform for browserify must be enabled in order to automatically compile and include referenced Marko template files.
```bash
# Install the markoify plugin from npm:
@ -433,7 +433,7 @@ The Marko compiler produces a Node.js-compatible, CommonJS module as output. Thi
The `marko` module will automatically compile templates loaded by your application on the server, but you can also choose to precompile all templates. This can be helpful as a build or test step to catch errors early.
You can either use the command line interface or the JavaScript API to compile a Raptor Template file. To use the CLI you must first install the `marko` module globally using the following command:
You can either use the command line interface or the JavaScript API to compile a Marko template file. To use the CLI you must first install the `marko` module globally using the following command:
```bash
npm install marko --global
```
@ -614,7 +614,7 @@ For example, both of the following are valid and equivalent:
## Includes
Other Raptor Template files can be included using the `<c-include>` tag and a relative path. For example:
Other Marko files can be included using the `<c-include>` tag and a relative path. For example:
```html
<c-include template="./greeting.marko" name="Frank" count="30"/>
@ -1032,7 +1032,7 @@ Output:
## Helpers
Since Raptor Template files compile into CommonJS modules, any Node.js module can be "imported" into a template for use as a helper module. For example, given the following helper module:
Since Marko template files compile into CommonJS modules, any Node.js module can be "imported" into a template for use as a helper module. For example, given the following helper module:
_src/util.js_:
```javascript

View File

@ -1,4 +1,4 @@
var raptorTemplatesCompiler = require('../compiler');
var markoCompiler = require('../compiler');
var fs = require('fs');
var nodePath = require('path');
var Minimatch = require('minimatch').Minimatch;
@ -250,7 +250,7 @@ if (args.clean) {
var outPath = path + '.js';
console.log('Compiling:\n Input: ' + relPath(path) + '\n Output: ' + relPath(outPath) + '\n');
context.beginAsync();
raptorTemplatesCompiler.compileFile(path, function(err, src) {
markoCompiler.compileFile(path, function(err, src) {
if (err) {
failed.push('Failed to compile "' + path + '". Error: ' + (err.stack || err));
context.endAsync(err);

View File

@ -1,7 +1,7 @@
var nodePath = require('path');
var fs = require('fs');
var Module = require('module').Module;
var raptorTemplatesCompiler = require('../compiler');
var markoCompiler = require('../compiler');
var cwd = process.cwd();
function loadSource(templatePath, compiledSrc) {
@ -23,7 +23,7 @@ module.exports = function load(templatePath) {
templatePath = nodePath.resolve(cwd, templatePath);
var targetFile = templatePath + '.js';
var compiler = raptorTemplatesCompiler.createCompiler(templatePath);
var compiler = markoCompiler.createCompiler(templatePath);
var isUpToDate = compiler.checkUpToDate(targetFile);
if (isUpToDate) {
return require(targetFile);

View File

@ -4,7 +4,7 @@ chai.Assertion.includeStack = true;
require('chai').should();
var expect = require('chai').expect;
var nodePath = require('path');
var raptorTemplates = require('../');
var marko = require('../');
var through = require('through');
describe('marko/api' , function() {
@ -19,7 +19,7 @@ describe('marko/api' , function() {
});
it('should allow a template to be rendered using a callback', function(done) {
raptorTemplates.render(
marko.render(
nodePath.join(__dirname, 'test-project/hello.marko'),
{
name: 'John'
@ -35,7 +35,7 @@ describe('marko/api' , function() {
});
it('should allow a template to be rendered to a context wrapping a string builder', function(done) {
var context = raptorTemplates.createContext();
var context = marko.createContext();
context
.on('end', function() {
expect(context.getOutput()).to.equal('Hello John!');
@ -45,7 +45,7 @@ describe('marko/api' , function() {
done(e);
});
raptorTemplates.render(
marko.render(
nodePath.join(__dirname, 'test-project/hello.marko'),
{
name: 'John'
@ -62,7 +62,7 @@ describe('marko/api' , function() {
output += data;
});
var context = raptorTemplates.createContext(stream);
var context = marko.createContext(stream);
context
.on('end', function() {
expect(output).to.equal('Hello John!');
@ -72,7 +72,7 @@ describe('marko/api' , function() {
done(e);
});
raptorTemplates.render(
marko.render(
nodePath.join(__dirname, 'test-project/hello.marko'),
{
name: 'John'
@ -91,7 +91,7 @@ describe('marko/api' , function() {
});
raptorTemplates.stream(
marko.stream(
nodePath.join(__dirname, 'test-project/hello.marko'),
{
name: 'John'
@ -110,7 +110,7 @@ describe('marko/api' , function() {
/// TEMPLATE LOADING:
it('should allow a template to be loaded and rendered using a callback', function(done) {
var template = raptorTemplates.load(nodePath.join(__dirname, 'test-project/hello.marko'));
var template = marko.load(nodePath.join(__dirname, 'test-project/hello.marko'));
template.render({
name: 'John'
},
@ -125,7 +125,7 @@ describe('marko/api' , function() {
});
it('should allow a template to be loaded and rendered to a context wrapping a string builder', function(done) {
var context = raptorTemplates.createContext();
var context = marko.createContext();
context
.on('end', function() {
expect(context.getOutput()).to.equal('Hello John!');
@ -135,7 +135,7 @@ describe('marko/api' , function() {
done(e);
});
var template = raptorTemplates.load(nodePath.join(__dirname, 'test-project/hello.marko'));
var template = marko.load(nodePath.join(__dirname, 'test-project/hello.marko'));
template.render({
name: 'John'
},
@ -152,7 +152,7 @@ describe('marko/api' , function() {
output += data;
});
var context = raptorTemplates.createContext(stream);
var context = marko.createContext(stream);
context
.on('end', function() {
expect(output).to.equal('Hello John!');
@ -162,7 +162,7 @@ describe('marko/api' , function() {
done(e);
});
var template = raptorTemplates.load(nodePath.join(__dirname, 'test-project/hello.marko'));
var template = marko.load(nodePath.join(__dirname, 'test-project/hello.marko'));
template.render({
name: 'John'
},
@ -172,7 +172,7 @@ describe('marko/api' , function() {
});
it('should allow a template to be loaded and rendered to a stream', function(done) {
var template = raptorTemplates.load(nodePath.join(__dirname, 'test-project/hello.marko'));
var template = marko.load(nodePath.join(__dirname, 'test-project/hello.marko'));
var output = '';
var outStream = through(function write(data) {
@ -194,13 +194,13 @@ describe('marko/api' , function() {
});
it('should allow a template to be rendered to a string synchronously using renderSync', function() {
var template = raptorTemplates.load(nodePath.join(__dirname, 'test-project/hello.marko'));
var template = marko.load(nodePath.join(__dirname, 'test-project/hello.marko'));
var output = template.renderSync({ name: 'John' });
expect(output).to.equal('Hello John!');
});
it('should throw an error if beginAsync is used with renderSync', function() {
var template = raptorTemplates.load(nodePath.join(__dirname, 'test-project/hello-async.marko'));
var template = marko.load(nodePath.join(__dirname, 'test-project/hello-async.marko'));
var output;
var e;
@ -221,7 +221,7 @@ describe('marko/api' , function() {
});
it('should throw errors correctly with renderSync', function() {
var template = raptorTemplates.load(nodePath.join(__dirname, 'test-project/hello-error.marko'));
var template = marko.load(nodePath.join(__dirname, 'test-project/hello-error.marko'));
var output;
var e;

View File

@ -36,8 +36,8 @@ function testRender(path, data, done, options) {
var raptorTemplates = require('../');
var Context = raptorTemplates.Context;
var marko = require('../');
var Context = marko.Context;
var context = options.context || new Context(new StringBuilder());
require('../compiler').defaultOptions.checkUpToDate = false;
@ -47,7 +47,7 @@ function testRender(path, data, done, options) {
dataProviders.register(options.dataProviders);
}
raptorTemplates.render(inputPath, data, context)
marko.render(inputPath, data, context)
.on('end', function() {
var output = context.getOutput();

View File

@ -26,14 +26,14 @@ function testRender(path, data, done, options) {
var raptorTemplates = require('../');
var marko = require('../');
require('../compiler').defaultOptions.checkUpToDate = false;
var Context = raptorTemplates.Context;
var Context = marko.Context;
var context = options.context || new Context(new StringBuilder());
raptorTemplates.render(inputPath, data, context)
marko.render(inputPath, data, context)
.on('end', function() {
var output = context.getOutput();

View File

@ -26,11 +26,11 @@ function testRender(path, data, done, options) {
require('../compiler').defaultOptions.checkUpToDate = false;
var raptorTemplates = require('../');
var Context = raptorTemplates.Context;
var marko = require('../');
var Context = marko.Context;
var context = options.context || new Context(new StringBuilder());
raptorTemplates.render(inputPath, data, context)
marko.render(inputPath, data, context)
.on('end', function() {
var output = context.getOutput();

View File

@ -1,7 +1,7 @@
var raptorTemplates = require('../../');
var marko = require('../../');
exports.render = function(input, context) {
raptorTemplates.render(require.resolve('./popover.marko'), {
marko.render(require.resolve('./popover.marko'), {
content: input.content,
title: input.title,
tag: input

View File

@ -1,4 +1,4 @@
var raptorTemplates = require('../../');
var marko = require('../../');
exports.render = function(input, context) {
var tabs = [],
@ -24,7 +24,7 @@ exports.render = function(input, context) {
tab.divClass = tab.active ? "tab-pane active" : "tab-pane";
});
raptorTemplates.render(require.resolve('./tabs.marko'), {
marko.render(require.resolve('./tabs.marko'), {
tabs: tabs
}, context);