1.2.0 • Published 11 years ago

rex-template v1.2.0

Weekly downloads
2
License
-
Repository
github
Last release
11 years ago
╭━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╮
⌦  Hi, I'm Rex-Template. I'm here to make your life easier. ⌫
╰━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╯

Rex-Template

Install it in the root of your project, run rex-template -w, and just start building your website. Easy as pie.

No, Seriously. WTF is this?

Rex-Template recursively compiles all of the Handlebars templates in a folder into a single file, watching for changes afterward.

How do I use the templates once they're compiled?

Rex-Template compiles the templates it finds into a namespaced extension of the Handlebars.templates object, without the file extension (.hb,.hbs,.handlebars, etc)

####Take for example:

Folder Structure (> is Folder, - is file)

> BaseProjectFolder
  > protected
  > public
    > images
    > css
    > js
      > libs
      > templates
        - home.hb
        > user
          - avatar.hb
          - settings.hb
        > dashboard
          > graphs
            - tallGraph.hb
            - shortGraph.hb
          > feed
            - entry.hb
          - main.hb
        > navigation
          - bar.hb
          - menuLeft.hb
          - menuRight.hb

Now, simply navigate to the BaseProjectFolder and run rex-template on the command line. You should now have the following templates, ready to use in your code:

  • Handlebars.templates['home']
  • Handlebars.templates['user/avatar']
  • Handlebars.templates['user/settings']
  • Handlebars.templates['dashboard/graphs/tallGraph']
  • Handlebars.templates['dashboard/graphs/shortGraph']
  • Handlebars.templates['dashboard/feed/entry']
  • Handlebars.templates['dashboard/main']
  • Handlebars.templates['navigation/bar']
  • Handlebars.templates['navigation/menuLeft']
  • Handlebars.templates['navigation/menuRight']

How do I use them in my code?

Exactly the way that I listed above. Instead of doing this:

var template = Handlebars.compile( $("#someElement").html() )
$("#anotherElement").html( template({ name : "Blah", age : "BlahBlah" }) )  

You would instead do this:

$("#anotherElement").html( Handlebars.templates['some/template']({ name : "Blah", age : "BlahBlah" }) )  

I'm stuck and need help.

Email me. Pierce Moore me@prex.io

GitHub repo?

Sure do. rex/rex-template

I heard a rumor you do a cool nerdy trick with versions...

Sure do. Run Rex-Template with the -v flag and you will see your version of Rex-Template, Handlebars, Node, and the V8 Engine.

Rex-Template Version Tree:  
  Rex-Template:  [ 1.1.5 ]  
  Handlebars:    [ 1.0.0 ]  
  Node.js:       [ 0.10.9 ]  
  V8 (Engine):   [ 3.14.5.9 ]  

How do I use this thing?

####rex-template

Compiles ./public/js/templates into ./public/js/templates.js.

####rex-template -w

Compiles the folder of templates and and watches the folder for changes.

####rex-template

Compiles the folder of templates and reduces the text logged to the console.

####rex-template -i './other/templates/folder/' -o './js/folder/templates.js' -wq

Changes the input/output paths, reduces console logging, and watches for changes.

Does Rex-Template have awesome Command-Line flags?

Pshh, is that even a question?

FlagWhat it doesDefault Value
-h, --helpShow usage informationboolean
-i, --inFolder of templates to compiledefault: "./public/js/templates"
-o, --outCompiled output filedefault: "./public/js/templates.js"
-m, --minifyRemove extra comments and whitespaceboolean
-w, --watchMonitor the input folder for changesboolean
-v, --versionDisplay the version treeboolean
-q, --quietReduce console outputboolean

Have fun, kids!

1.2.0

11 years ago

1.1.75

11 years ago

1.1.74

11 years ago

1.1.73

11 years ago

1.1.72

11 years ago

1.1.71

11 years ago

1.1.7

11 years ago

1.1.6

11 years ago

1.1.5

11 years ago

1.1.4

11 years ago

1.1.3

11 years ago

1.1.2

11 years ago

1.1.1

11 years ago

1.0.2

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago

0.1.0

11 years ago

0.0.1

11 years ago