From fba01d926ac04d31df9b619204c2639e8da0859b Mon Sep 17 00:00:00 2001 From: Nikita Vasilyev Date: Mon, 21 May 2012 16:26:33 +0400 Subject: [PATCH 1/7] Document binary's arguments --- bin/ojster | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/ojster b/bin/ojster index 0ce0839..3dfcad9 100755 --- a/bin/ojster +++ b/bin/ojster @@ -1,13 +1,14 @@ #!/usr/bin/env node -var argv = require('optimist').argv; -var ojster = require('../'); +var optimist = require('optimist'); +optimist.usage('Usage: $0 srcPath [dstPath] --goog [str] --tab [num]'); -var args = argv._; +var ojster = require('../'); +var argv = optimist.argv._; var l = args.length; if (l < 1) { - abort('srcPath argument required'); + abort(optimist.help() + 'srcPath argument is required'); } var srcPath = args[0]; From 820ac1387d4ce6a591c060d790f7632f728f9b72 Mon Sep 17 00:00:00 2001 From: Nikita Vasilyev Date: Mon, 21 May 2012 16:39:51 +0400 Subject: [PATCH 2/7] Grammar nits https://www.google.com/search?q=%22template+engine+which%22 --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index f5e9cc2..b18175f 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ # Ojster -Ojster is "objective javascript templater" - dead simple template engine which translates .ojst templates into javascript classes capable of template content rendering. +Ojster is "objective javascript templater" - dead simple template engine that translates .ojst templates into javascript classes capable of template content rendering. TextMate bundle for Ojster can be found here: https://github.com/4u/Ojster.tmbundle From b6521c167b0340c444df3b13f6bb34e09f70f9b9 Mon Sep 17 00:00:00 2001 From: Nikita Vasilyev Date: Mon, 21 May 2012 16:45:48 +0400 Subject: [PATCH 3/7] s/need to/have to/ http://forum.wordreference.com/showthread.php?t=1437607 --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index b18175f..1cedc31 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ # Ojster -Ojster is "objective javascript templater" - dead simple template engine that translates .ojst templates into javascript classes capable of template content rendering. +Ojster is "objective javascript templater" -- dead simple template engine that translates .ojst templates into javascript classes capable of rendering templates content. TextMate bundle for Ojster can be found here: https://github.com/4u/Ojster.tmbundle @@ -10,7 +10,7 @@ TextMate bundle for Ojster can be found here: https://github.com/4u/Ojster.tmbun * Templates need "compilation" _(similar to Google Closure Templates)_ * Compiled template is a regular JS class -Templates use full power of JS with minimal additions of non-JS syntax. You don't need to learn lot of new stuff, because you already know the language that is powerful enough to manage your templates. Ojster does not stop you from doing terrible things in templates, just like JS hardly stops you from writing terrible code. You can easily use any dirty tricks, but generally you shouldn't. Be good all the time and be evil only when you really have to. +Templates use full power of JS with minimal additions of non-JS syntax. You don't have to learn lot of new stuff, because you already know the language that is powerful enough to manage your templates. Ojster does not stop you from doing terrible things in templates, just like JS hardly stops you from writing terrible code. You can easily use any dirty tricks, but generally you shouldn't. Be good all the time and be evil only when you really have to. Ojster provides tags and other non-JS constructions only as a syntax sugar and to hide differences between various frameworks' inheritance and module systems. With compilation templates are faster and have less errors, because they are already parsed and checked when it's time to render. From 8c8b8204d195822c48441c5b2735f6607866ce2a Mon Sep 17 00:00:00 2001 From: Nikita Vasilyev Date: Mon, 21 May 2012 16:56:36 +0400 Subject: [PATCH 4/7] Typos --- Readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index 1cedc31..9b89d82 100644 --- a/Readme.md +++ b/Readme.md @@ -10,11 +10,11 @@ TextMate bundle for Ojster can be found here: https://github.com/4u/Ojster.tmbun * Templates need "compilation" _(similar to Google Closure Templates)_ * Compiled template is a regular JS class -Templates use full power of JS with minimal additions of non-JS syntax. You don't have to learn lot of new stuff, because you already know the language that is powerful enough to manage your templates. Ojster does not stop you from doing terrible things in templates, just like JS hardly stops you from writing terrible code. You can easily use any dirty tricks, but generally you shouldn't. Be good all the time and be evil only when you really have to. +Templates use full power of JS with minimal additions of non-JS syntax. You don't have to learn a lot of new stuff, because you already know the language that is powerful enough to manage your templates. Ojster does not stop you from doing terrible things in templates, just like JS hardly stops you from writing terrible code. You can easily use any dirty tricks, but generally you shouldn't. Be good all the time and be evil only when you really have to. Ojster provides tags and other non-JS constructions only as a syntax sugar and to hide differences between various frameworks' inheritance and module systems. With compilation templates are faster and have less errors, because they are already parsed and checked when it's time to render. -Compilation is as simple and straight as possible. It always clear what final code will look like. And you can manage this code as any other code in your project - check with linter or your other favorite tool, compress with JS-compressor and so on. +Compilation is as simple and straightforward as possible. It's always clear what final code will look like. And you can manage this code as any other code in your project - check it with a linter or any other favorite tool, compress with JS-compressor and so on. Template is a regular JS class, so you can inherit it from any other class or inherit some class from it or do whatever you usually do with your classes. ## Features @@ -24,12 +24,12 @@ Template is a regular JS class, so you can inherit it from any other class or in * Google Closure Library * _other frameworks support can be added easily_ * Same template file _(if properly written)_ can be used to produce code for both node.js and Google Closure Library -* Template blocks can be overriden _(similar to Django templates' blocks, but more rich)_ +* Template blocks can be overridden _(similar to Django templates' blocks, but more rich)_ * Parametrized template blocks are yet not ready, but planned * Any JS constructions allowed _(for, if, etc.)_ * "Filters" are NOT supported _(use JS code instead)_ -Compilation is very fast because it's dumb simple. All JS fragments of template are transferred to final code literally. Template blocks are translated into regular methods of compiled JS class. These methods capable of appending corresponding content and nothing more. They can be called any number of times at any place of template, overriden in child templates and so on. +Compilation is very fast because it's damn simple. All JS fragments of template are transferred to final code literally. Template blocks are translated into regular methods of compiled JS class. These methods capable of appending corresponding content and nothing more. They can be called any number of times at any place of template, overridden in child templates and so on. ## Syntax From a6e4119e1f77cfbf5150256d74a4d044a68da925 Mon Sep 17 00:00:00 2001 From: Nikita Vasilyev Date: Mon, 21 May 2012 17:10:46 +0400 Subject: [PATCH 5/7] Use past simple tense instead of future simple tense. --- Readme.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Readme.md b/Readme.md index 9b89d82..ad5186a 100644 --- a/Readme.md +++ b/Readme.md @@ -14,7 +14,7 @@ Templates use full power of JS with minimal additions of non-JS syntax. You don' Ojster provides tags and other non-JS constructions only as a syntax sugar and to hide differences between various frameworks' inheritance and module systems. With compilation templates are faster and have less errors, because they are already parsed and checked when it's time to render. -Compilation is as simple and straightforward as possible. It's always clear what final code will look like. And you can manage this code as any other code in your project - check it with a linter or any other favorite tool, compress with JS-compressor and so on. +Compilation is as simple and straightforward as possible. It's always clear what final code looks like. And you can manage this code as any other code in your project - check it with a linter or any other favorite tool, compress with JS-compressor and so on. Template is a regular JS class, so you can inherit it from any other class or inherit some class from it or do whatever you usually do with your classes. ## Features @@ -34,15 +34,15 @@ Compilation is very fast because it's damn simple. All JS fragments of template ## Syntax It's recommended to take a look at `examples` directory before continue to read. Examples are very simple and intuitive. -By examining .ojst files and their corresponding .js files (compilation results) you will understand how template code is translated into JS code clearly enough. Further reading will provide you with details you could missed. +By examining .ojst files and their corresponding .js files (compilation results) you will understand how template code is translated into JS code clearly enough. Further reading provides you with details you could missed. Template syntax is similar to EJS, but it has some extra conceptions. All the special constructions are enclosed within `<% %>` tags: -* `<%= ... %>` - calculate expression and render result escaped. Will be translated into something like `this.append(this.escape(...))` -* `<%- ... %>` - calculate expression and render result unescaped. Will be translated into something like `this.append(...)` +* `<%= ... %>` - calculate an expression and render result escaped. Translates into something like `this.append(this.escape(...))` +* `<%- ... %>` - calculate an expression and render result unescaped. Translates into something like `this.append(...)` * `<% @commandName ... %>` - one of the commands _(described below)_. -* `<% ... %>` - raw JS code fragment. Will be transferred literally. Can contain any JS code including `this.append(...)` calls. +* `<% ... %>` - a raw JS code fragment. Transferees literally. Can contain any JS code including `this.append(...)` calls. ### Commands @@ -65,8 +65,8 @@ _...other command descriptions to be added..._ * `<% @block blockName { %>` - opens block _blockName_ * `<% @block blockName } %>` - closes block _blockName_ (blockName is optional here) -Code related to content between these two commands will be placed to _appendBlockBlockName_ method of resulting template class. -Blocks can be nested. If block is nested corresponding method call will be placed in appropriate place of nesting block. +Code related to content between these two commands goes into _appendBlockBlockName_ method of resulting template class. +Blocks can be nested. When block is nested then corresponding method call goes into appropriate place of nesting block. <% @block A { %> a @@ -75,7 +75,7 @@ Blocks can be nested. If block is nested corresponding method call will be place <% @block } %> <% @block } %> -will be translated into something like +translates into something like TemplateClass.prototype.appendBlockA = function() { this.append('a'); @@ -86,7 +86,7 @@ will be translated into something like this.append('b'); }; -Note, that nested blocks haven't access to local variables of nesting block, because blocks are translated into completely separated (not nested) functions. Following example will not work as expected: +Note, that nested blocks does not have an access to local variables of nested block, because blocks are translated into completely separated (not nested) functions. The following example doesn't work as you might expect: <% @block A { %> <% for (var i=0; i<10; i++) { %> @@ -96,7 +96,7 @@ Note, that nested blocks haven't access to local variables of nesting block, bec <% } %> <% @block } %> -This examples will be translated into something like this: +The examples translate into something like this: TemplateClass.prototype.appendBlockA = function() { for (var i=0; i<10; i++) { @@ -108,12 +108,12 @@ This examples will be translated into something like this: this.append(i); }; -And of course `i` is undefined within `appendBlockB` function scope. Use parametrized blocks to transfer local variables into scope of nested block. +And of course `i` is undefined within `appendBlockB` function scope. Use parametrized blocks to transfer local variables into scope of a nested block. -`<% @block blockName {} %>` - opens and closes block _blockName_. Such an empty block can be defined to be overriden in child templates. +`<% @block blockName {} %>` - opens and closes block _blockName_. Such an empty block can be defined to be overridden in child templates. -`main` is a special block name indicating a block that will be appended on template's `render()` method call. -By default, text outside of any block will be supposed to be a raw JS code. +`main` is a special block name indicating a block that appends to template's `render()` method call. +By default, text outside of any block can be a raw JS code. ## Readme TODO From fbb241733e921d1e2cb487a2043bf48b16b56586 Mon Sep 17 00:00:00 2001 From: Nikita Vasilyev Date: Mon, 21 May 2012 17:16:51 +0400 Subject: [PATCH 6/7] Whoops, GitHub version of Markdown does not support `--` as em dash --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index ad5186a..cdff0a8 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ # Ojster -Ojster is "objective javascript templater" -- dead simple template engine that translates .ojst templates into javascript classes capable of rendering templates content. +Ojster is "objective javascript templater" — dead simple template engine that translates .ojst templates into javascript classes capable of rendering templates content. TextMate bundle for Ojster can be found here: https://github.com/4u/Ojster.tmbundle From 8d8f68b81fdc54d2e5bb46fb447611efb6cd8fb7 Mon Sep 17 00:00:00 2001 From: Nikita Vasilyev Date: Mon, 21 May 2012 19:24:23 +0400 Subject: [PATCH 7/7] Document --goog and --tab --- bin/ojster | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/ojster b/bin/ojster index 3dfcad9..f638a8b 100755 --- a/bin/ojster +++ b/bin/ojster @@ -1,14 +1,18 @@ #!/usr/bin/env node var optimist = require('optimist'); -optimist.usage('Usage: $0 srcPath [dstPath] --goog [str] --tab [num]'); +optimist.usage('Usage: $0 srcPath [dstPath] --tab [num] --goog --scope'); +optimist.boolean('goog').describe('goog', 'Use Google Closure module system.'); +optimist.describe('tab', 'Replace tabs with given number of spaces.'); +optimist.describe('scope', 'FIXME'); var ojster = require('../'); -var argv = optimist.argv._; +var argv = optimist.argv; +var args = argv._; var l = args.length; if (l < 1) { - abort(optimist.help() + 'srcPath argument is required'); + abort(optimist.help()); } var srcPath = args[0];