示例#1
0
        public void Run(string export = "all.js", bool debug = false)
        {
            foreach (var path in _templates)
            {
                var name = path.Replace(_root, "")
                           .Replace("_template\\", "")
                           .Replace("template\\", "")
                           .Replace(".hbs", "")
                           .Replace(".handlebars", "")
                           .Replace("\\", "/")
                           .Trim('/')
                           .ToLower();

                Console.WriteLine("Compiling template \"" + name + "\"");

                var template = CompactTemplate(File.ReadAllText(path, System.Text.Encoding.UTF8));

                EnsurePartial(template);

                _handlebars.Compile(name, template);
                if (debug)
                {
                    _handlebars.ExportPrecompile();
                }
            }

            File.WriteAllText(export,
                              _handlebars.ExportPrecompile(),
                              System.Text.Encoding.UTF8);

            _handlebars.Clear();
        }
示例#2
0
        public void GetPreCompileJS()
        {
            _engine.Compile("test-precompile", template);
            var test = _engine.ExportPrecompile();

            // note: yui compress can gain 50% before gzip, 70% after.
            Assert.IsNotNull(test);
        }
示例#3
0
        public void CompileThenExportPrecompile()
        {
            _engine.Compile("test-then-export-precompile", "<body>{{body}}</body>");
            var result = _engine.ExportPrecompile();

            Assert.IsNotNull(result);
        }