Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. 'use strict';
  2. var lib = require('./src/lib');
  3. var _require = require('./src/environment'),
  4. Environment = _require.Environment,
  5. Template = _require.Template;
  6. var Loader = require('./src/loader');
  7. var loaders = require('./src/loaders');
  8. var precompile = require('./src/precompile');
  9. var compiler = require('./src/compiler');
  10. var parser = require('./src/parser');
  11. var lexer = require('./src/lexer');
  12. var runtime = require('./src/runtime');
  13. var nodes = require('./src/nodes');
  14. var installJinjaCompat = require('./src/jinja-compat'); // A single instance of an environment, since this is so commonly used
  15. var e;
  16. function configure(templatesPath, opts) {
  17. opts = opts || {};
  18. if (lib.isObject(templatesPath)) {
  19. opts = templatesPath;
  20. templatesPath = null;
  21. }
  22. var TemplateLoader;
  23. if (loaders.FileSystemLoader) {
  24. TemplateLoader = new loaders.FileSystemLoader(templatesPath, {
  25. watch: opts.watch,
  26. noCache: opts.noCache
  27. });
  28. } else if (loaders.WebLoader) {
  29. TemplateLoader = new loaders.WebLoader(templatesPath, {
  30. useCache: opts.web && opts.web.useCache,
  31. async: opts.web && opts.web.async
  32. });
  33. }
  34. e = new Environment(TemplateLoader, opts);
  35. if (opts && opts.express) {
  36. e.express(opts.express);
  37. }
  38. return e;
  39. }
  40. module.exports = {
  41. Environment: Environment,
  42. Template: Template,
  43. Loader: Loader,
  44. FileSystemLoader: loaders.FileSystemLoader,
  45. NodeResolveLoader: loaders.NodeResolveLoader,
  46. PrecompiledLoader: loaders.PrecompiledLoader,
  47. WebLoader: loaders.WebLoader,
  48. compiler: compiler,
  49. parser: parser,
  50. lexer: lexer,
  51. runtime: runtime,
  52. lib: lib,
  53. nodes: nodes,
  54. installJinjaCompat: installJinjaCompat,
  55. configure: configure,
  56. reset: function reset() {
  57. e = undefined;
  58. },
  59. compile: function compile(src, env, path, eagerCompile) {
  60. if (!e) {
  61. configure();
  62. }
  63. return new Template(src, env, path, eagerCompile);
  64. },
  65. render: function render(name, ctx, cb) {
  66. if (!e) {
  67. configure();
  68. }
  69. return e.render(name, ctx, cb);
  70. },
  71. renderString: function renderString(src, ctx, cb) {
  72. if (!e) {
  73. configure();
  74. }
  75. return e.renderString(src, ctx, cb);
  76. },
  77. precompile: precompile ? precompile.precompile : undefined,
  78. precompileString: precompile ? precompile.precompileString : undefined
  79. };