summaryrefslogtreecommitdiffstats
path: root/bin/handlebars
blob: 4ed98b3727442197a5865be62f4fc6272e3ed24e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env node

var optimist = require('optimist')
    .usage('Precompile handlebar templates.\nUsage: $0 [template|directory]...', {
      'f': {
        'type': 'string',
        'description': 'Output File',
        'alias': 'output'
      },
      'map': {
        'type': 'string',
        'description': 'Source Map File'
      },
      'a': {
        'type': 'boolean',
        'description': 'Exports amd style (require.js)',
        'alias': 'amd'
      },
      'c': {
        'type': 'string',
        'description': 'Exports CommonJS style, path to Handlebars module',
        'alias': 'commonjs',
        'default': null
      },
      'h': {
        'type': 'string',
        'description': 'Path to handlebar.js (only valid for amd-style)',
        'alias': 'handlebarPath',
  	    'default': ''
      },
      'k': {
        'type': 'string',
        'description': 'Known helpers',
        'alias': 'known'
      },
      'o': {
        'type': 'boolean',
        'description': 'Known helpers only',
        'alias': 'knownOnly'
      },
      'm': {
        'type': 'boolean',
        'description': 'Minimize output',
        'alias': 'min'
      },
      'n': {
        'type': 'string',
        'description': 'Template namespace',
        'alias': 'namespace',
        'default': 'Handlebars.templates'
      },
      's': {
        'type': 'boolean',
        'description': 'Output template function only.',
        'alias': 'simple'
      },
      'r': {
        'type': 'string',
        'description': 'Template root. Base value that will be stripped from template names.',
        'alias': 'root'
      },
      'p' : {
        'type': 'boolean',
        'description': 'Compiling a partial template',
        'alias': 'partial'
      },
      'd' : {
        'type': 'boolean',
        'description': 'Include data when compiling',
        'alias': 'data'
      },
      'e': {
        'type': 'string',
        'description': 'Template extension.',
        'alias': 'extension',
        'default': 'handlebars'
      },
      'b': {
        'type': 'boolean',
        'description': 'Removes the BOM (Byte Order Mark) from the beginning of the templates.',
        'alias': 'bom'
      },
      'v': {
        'type': 'boolean',
        'description': 'Prints the current compiler version',
        'alias': 'version'
      },

      'help': {
        'type': 'boolean',
        'description': 'Outputs this message'
      }
    })

    .check(function(argv) {
      if (argv.version) {
        return;
      }
    });


var argv = optimist.argv;
argv.templates = argv._;
delete argv._;

if (argv.help || (!argv.templates.length && !argv.version)) {
  optimist.showHelp();
  return;
}

return require('../dist/cjs/precompiler').cli(argv);