This commit is contained in:
2019-01-25 01:39:48 +01:00
commit 41ac3fb32a
3269 changed files with 396937 additions and 0 deletions

1
node_modules/express-handlebars/.idea/.name generated vendored Normal file
View File

@@ -0,0 +1 @@
express-handlebars

6
node_modules/express-handlebars/.idea/encodings.xml generated vendored Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="express-handlebars node_modules" level="project" />
</component>
</module>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="file://$PROJECT_DIR$" libraries="{express-handlebars node_modules}" />
</component>
</project>

View File

@@ -0,0 +1,14 @@
<component name="libraryTable">
<library name="express-handlebars node_modules" type="javaScript">
<properties>
<option name="frameworkName" value="node_modules" />
<sourceFilesUrls>
<item url="file://$PROJECT_DIR$/node_modules" />
</sourceFilesUrls>
</properties>
<CLASSES>
<root url="file://$PROJECT_DIR$/node_modules" />
</CLASSES>
<SOURCES />
</library>
</component>

17
node_modules/express-handlebars/.idea/misc.xml generated vendored Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JsBowerSettings">
<exe-path>/usr/local/bin/bower</exe-path>
<config-path />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
</project>

8
node_modules/express-handlebars/.idea/modules.xml generated vendored Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/express-handlebars.iml" filepath="$PROJECT_DIR$/.idea/express-handlebars.iml" />
</modules>
</component>
</project>

6
node_modules/express-handlebars/.idea/vcs.xml generated vendored Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

256
node_modules/express-handlebars/.idea/workspace.xml generated vendored Normal file
View File

@@ -0,0 +1,256 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="ea8cf2ac-fdc7-42e9-932c-9eb161027e9b" name="Default" comment="" />
<ignored path="express-handlebars.iws" />
<ignored path=".idea/workspace.xml" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
<component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FavoritesManager">
<favorites_list name="express-handlebars" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="package.json" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.6057692">
<caret line="21" column="4" selection-start-line="21" selection-start-column="4" selection-end-line="21" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="utils.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/utils.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/package.json" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" />
<component name="JsBuildToolPackageJson" detection-done="true">
<package-json value="$PROJECT_DIR$/package.json" />
</component>
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
</component>
<component name="ProjectFrameBounds">
<option name="x" value="477" />
<option name="y" value="165" />
<option name="width" value="910" />
<option name="height" value="638" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="express-handlebars" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="express-handlebars" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="express-handlebars" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="express-handlebars" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="express-handlebars" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="lib" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="settings.editor.selected.configurable" value="configurable.group.tools" />
<property name="settings.editor.splitter.proportion" value="0.2" />
<property name="HbShouldOpenHtmlAsHb" value="" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="js-jscs-nodeInterpreter" value="/usr/local/bin/node" />
</component>
<component name="RunManager">
<configuration default="true" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application">
<method />
</configuration>
<configuration default="true" type="DartUnitRunConfigurationType" factoryName="DartUnit">
<method />
</configuration>
<configuration default="true" type="JavaScriptTestRunnerKarma" factoryName="Karma" config-file="">
<envs />
<method />
</configuration>
<configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
<method />
</configuration>
<configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" working-dir="">
<method />
</configuration>
<configuration default="true" type="cucumber.js" factoryName="Cucumber.js">
<option name="cucumberJsArguments" value="" />
<option name="executablePath" />
<option name="filePath" />
<method />
</configuration>
<configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
<method />
</configuration>
<configuration default="true" type="js.build_tools.npm" factoryName="npm">
<command value="run-script" />
<scripts />
<envs />
<method />
</configuration>
<configuration default="true" type="mocha-javascript-test-runner" factoryName="Mocha">
<node-options />
<working-directory>$PROJECT_DIR$</working-directory>
<pass-parent-env>true</pass-parent-env>
<envs />
<ui>bdd</ui>
<extra-mocha-options />
<test-kind>DIRECTORY</test-kind>
<test-directory />
<recursive>false</recursive>
<method />
</configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="ea8cf2ac-fdc7-42e9-932c-9eb161027e9b" name="Default" comment="" />
<created>1453315609358</created>
<option name="number" value="Default" />
<updated>1453315609358</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="477" y="165" width="910" height="638" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24835165" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/utils.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.6057692">
<caret line="21" column="4" selection-start-line="21" selection-start-column="4" selection-end-line="21" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
</component>
</project>

1
node_modules/express-handlebars/.npmignore generated vendored Normal file
View File

@@ -0,0 +1 @@
examples/

368
node_modules/express-handlebars/HISTORY.md generated vendored Normal file
View File

@@ -0,0 +1,368 @@
Express Handlebars Change History
=================================
3.0.0 (2016-01-26)
------------------
* Upgraded to Handlebars 4.0. ([#142][])
2.0.1 (2015-04-23)
------------------
* Guarded against unexpected Handlebars API change that was released in a patch.
([#125][])
[#125]: https://github.com/ericf/express-handlebars/issues/125
2.0.0 (2015-03-22)
------------------
* __[!]__ Upgraded to Handlebars 3.0 by default, but still works with Handlebars
2.x by using the `handlebars` config option. ([#105][])
* __[!]__ Removed using prototype properties for default config values. The
default values are now embedded in the constructor. ([#105][])
* __[!]__ Removed `handlebarsVersion` instance property and
`getHandlebarsSemver()` static function on the `ExpressHandlebars`
constructor. ([#105][])
* __[!]__ Replaced undocumented `compileTemplate()` hook with the protected but
supported `_compileTemplate()` and `_precompileTemplate()` hooks. ([#95][])
* Fixed layout path resolution on Windows. ([#113][] @Tineler)
* Added `compilerOptions` config property which is passed along to
`Handlebars.compile()` and `Handlebars.precompile()`. ([#95][])
* Exposed Express Handlebars metadata to the data channel during render. This
metadata is accessible via `{{@exphbs.*}}` ([#89][], [#101][])
* Added new "protected" hooks for AOP-ing template compilation and rendering,
all of which can optionally return a Promise: ([#105][])
* `_compileTemplate()`
* `_precompileTemplate()`
* `_renderTemplate()`
[#89]: https://github.com/ericf/express-handlebars/issues/89
[#95]: https://github.com/ericf/express-handlebars/issues/95
[#101]: https://github.com/ericf/express-handlebars/issues/101
[#105]: https://github.com/ericf/express-handlebars/issues/105
[#113]: https://github.com/ericf/express-handlebars/issues/113
1.2.2 (2015-03-06)
------------------
* Upgraded `glob` dependency to v5 which now officially supports symlinks via
the new `follow` option. ([#98][])
1.2.1 (2015-02-17)
------------------
* Locked down `glob` dependency to a v4 version range that is known to work with
this package _and_ support symlinks. The `glob` version can be updated when
[isaacs/node-glob#139](https://github.com/isaacs/node-glob/issues/139) is
resolved. ([#98][] @adgad)
[#98]: https://github.com/ericf/express-handlebars/issues/98
1.2.0 (2015-02-17)
------------------
* Added support for render-level `partials` to be specified when calling
`renderView()` (which is the method Express calls). The `options.partials`
value matches what Handlebars accepts during template rendering: it should
have the shape `{partialName: fn}` or be a Promise for such an object.
([#82][])
[#82]: https://github.com/ericf/express-handlebars/issues/82
1.1.0 (2014-09-14)
------------------
* __[!]__ Upgraded Handlebars to 2.0.0 final, it was beta before.
* Added support for `partialsDir` to be configured with a collection (or promise
for a collection) of templates, via the new `templates` prop in `partialDir`
config objects. This allows developers to hand Express Handlebars the compiled
partials templates to use for a specific partials dir.
([#81][] @joanniclaborde)
* Upgraded Promise dependency.
[#81]: https://github.com/ericf/express-handlebars/issues/81
1.0.3 (2014-09-05)
------------------
* Fixed issue with namespaced partials dirs not actually being namespaces.
([#76][] @inerte)
[#76]: https://github.com/ericf/express-handlebars/issues/76
1.0.2 (2014-09-05)
------------------
* Fixed `engines` entry in `package.json` to Node `>=0.10` to reflect this
package's requirements. ([#78][])
[#78]: https://github.com/ericf/express-handlebars/issues/78
1.0.1 (2014-08-08)
------------------
* Fixed bug where rendered content was only be returned if a layout template was
being used. Now a layout-less render will actually return content. ([#73][])
[#73]: https://github.com/ericf/express-handlebars/issues/73
1.0.0 (2014-08-07)
------------------
* __[!]__ Renamed to: `express-handlebars`. ([#65][])
* __[!]__ Rewritten to use Promises instead of `async` for asynchronous code.
([#68][]) This resulted in the following public API changes:
* `loadPartials()` --> `getPartials()`, returns a Promise.
* `loadTemplate()` --> `getTemplate()`, returns a Promise.
* `loadTemplates()` --> `getTemplates()`, returns a Promise.
* `render(file, context, [options])`, returns a Promise.
* `partialsDir` can now be set with an array of objects in the following form to
support namespaced partials: ([#70][] @joanniclaborde)
{ dir: 'foo/bar/', namespace: 'bar' }
* Added support for Handlebars' `data` channel via `options.data`. ([#62][])
* Added `compileTemplate()` hook for the pre/post compile process, this also
supports returning a Promise. ([#39][], [#41][])
* Added `_renderTemplate()` hook that supports returning a Promise.
([#39][], [#41][])
* Upgraded all dependencies, including Handlebars to 2.x. ([#59][])
* Added `graceful-fs` dependency to support large numbers of files to avoid
EMFILE errors.
* Reduced complexity of cache code.
* Updated examples to each be self-contained and have `package.json` files.
[#39]: https://github.com/ericf/express-handlebars/issues/39
[#41]: https://github.com/ericf/express-handlebars/issues/41
[#59]: https://github.com/ericf/express-handlebars/issues/59
[#62]: https://github.com/ericf/express-handlebars/issues/62
[#65]: https://github.com/ericf/express-handlebars/issues/65
[#68]: https://github.com/ericf/express-handlebars/issues/68
[#70]: https://github.com/ericf/express-handlebars/issues/70
0.5.1 (2014-08-05)
------------------
* __[!]__ Last release before `v1.0` which will have breaking changes.
* Improved `extname` docs in README and added example. ([#30][] @Crashthatch)
* `extname` can now be specified _without_ the leading `"."`.
([#51][] @calvinmetcalf)
[#30]: https://github.com/ericf/express-handlebars/issues/30
[#51]: https://github.com/ericf/express-handlebars/issues/51
0.5.0 (2013-07-25)
------------------
* Added `loadTemplates()` method which will load all the templates in a
specified directory. ([#21][])
* Added support for multiple partials directories. This enables the
`partialsDir` configuration property to be specified as an *array* of
directories, and loads all of the templates in each one.
This feature allows an app's partials to be split up in multiple directories,
which is common if an app has some shared partials which will also be exposed
to the client, and some server-side-only partials. ([#20][])
* Added runnable code examples in this package's "examples/" directory.
([#22][])
* Improved optional argument handling in public methods to treat Express
`locals` function objects as `options` and not `callback` params to the method
being invoked. ([#27][])
[#20]: https://github.com/ericf/express-handlebars/issues/20
[#21]: https://github.com/ericf/express-handlebars/issues/21
[#22]: https://github.com/ericf/express-handlebars/issues/22
[#27]: https://github.com/ericf/express-handlebars/issues/27
0.4.1 (2013-04-06)
------------------
* Updated `async` dependency to the latest stable minor version: "~0.2".
0.4.0 (2013-03-24)
------------------
* __[!]__ Removed the following "get" -> "load" aliases which kept in v0.2.0 for
back-compat:
* `getPartials()` -> `loadPartials()`
* `getTemplate()` -> `loadTemplate()`
This is the future version where these aliases have been removed.
* __[!]__ Renamed `lib/express3-handlebars.js` -> `lib/express-handlebars.js`.
* Exposed `getHandlebarsSemver()` function as a static property on the
`ExpressHandlebars` constructor.
* Rearranged module exports by moving the engine factory function to `index.js`,
making the `lib/express3-handlebars.js` module only responsible for exporting
the `ExpressHandlebars` constructor.
0.3.3 (2013-03-22)
------------------
* Updated internal `_resolveLayoutPath()` method to take the full
`options`/locals objects which the view is rendered with. This makes it easier
to override. ([#14][])
[#14]: https://github.com/ericf/express-handlebars/issues/14
0.3.2 (2013-02-20)
------------------
* Transfered ownership and copyright to Yahoo! Inc. This software is still free
to use, and is now licensed under the Yahoo! Inc. BSD license.
0.3.1 (2013-02-18)
------------------
* Updated README with info about `options.helpers` for `render()` and
`renderView()` docs. ([#7][])
[#7]: https://github.com/ericf/express-handlebars/issues/7
0.3.0 (2013-02-18)
------------------
* Added support for render-level helpers, via `options.helpers`, to the
`render()` and `renderView()` methods. Handlebars' `registerHelper()` function
now works as expected and does not have to be called before the
`ExpressHandlebars` instance is created. Helpers are now merged from:
`handlebars.helpers` (global), `helpers` (instance), and `options.helpers`
(render-level) before a template is rendered; this provides flexibility at
all levels. ([#3][], [#11][])
* Added `handlebarsVersion` property which is the version number of `handlebars`
as a semver. This is used internally to branch on certain operations which
differ between Handlebars releases.
[#3]: https://github.com/ericf/express-handlebars/issues/3
[#11]: https://github.com/ericf/express-handlebars/issues/11
0.2.3 (2013-02-13)
------------------
* Fixed issue with naming nested partials when using the latest version of
Handlebars (1.0.rc.2). Previous versions require a hack to replace "/"s with
"."s in partial names, and the latest version of Handlebars fixes that bug.
This hack will only be applied to old versions of Handlebars. ([#9][])
[#9]: https://github.com/ericf/express-handlebars/issues/9
0.2.2 (2013-02-04)
------------------
* Updated README with the public method renames which happened v0.2.0.
0.2.1 (2013-02-04)
------------------
* `extname`, `layoutsDir`, and `partialsDir` property values will now reference
the values on the prototype unless an `ExpressHandlebars` instance is
constructed with config values for these properties.
* Improved clarity of method implementations, and exposed more override "hooks"
via new private methods: `_getPartialName()`, `_renderTemplate()`, and
`_resolveLayoutPath()`.
0.2.0 (2013-02-01)
------------------
* __[!]__ Renamed methods prefixed with "get" to "load" for clarity:
* `getPartials()` -> `loadPartials()`
* `getTemplate()` -> `loadTemplate()`
Aliases for these methods have been created to maintain back-compat, but the
old method names are now deprecated will be removed in the future. ([#5][])
* All paths are resolved before checking in or adding to caches. ([#1][])
* Force `{precompiled: false}` option within `render()` and `renderView()`
methods to prevent trying to render with precompiled templates. ([#2][])
[#1]: https://github.com/ericf/express-handlebars/issues/1
[#2]: https://github.com/ericf/express-handlebars/issues/2
[#5]: https://github.com/ericf/express-handlebars/issues/5
0.1.2 (2013-01-10)
------------------
* Tweaked formatting of README documentation.
0.1.1 (2013-01-10)
------------------
* Added README documentation.
0.1.0 (2013-01-07)
------------------
* Initial release.

31
node_modules/express-handlebars/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,31 @@
Copyright (c) 2014, Yahoo Inc. All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of Yahoo Inc. nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of Yahoo Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

568
node_modules/express-handlebars/README.md generated vendored Normal file
View File

@@ -0,0 +1,568 @@
Express Handlebars
==================
A [Handlebars][] view engine for [Express][] which doesn't suck.
[![npm version][npm-badge]][npm]
[![dependency status][dep-badge]][dep-status]
**This package used to be named `express3-handlebars`. The previous `express-handlebars` package by @jneen can be found [here][jneen-exphbs].**
[Express]: https://github.com/visionmedia/express
[Handlebars]: https://github.com/wycats/handlebars.js
[npm]: https://www.npmjs.org/package/express-handlebars
[npm-badge]: https://img.shields.io/npm/v/express-handlebars.svg?style=flat-square
[dep-status]: https://david-dm.org/ericf/express-handlebars
[dep-badge]: https://img.shields.io/david/ericf/express-handlebars.svg?style=flat-square
[jneen-exphbs]: https://github.com/jneen/express-handlebars
## Goals & Design
I created this project out of frustration with the existing Handlebars view engines for Express. As of version 3.x, Express got out of the business of being a generic view engine — this was a great decision — leaving developers to implement the concepts of layouts, partials, and doing file I/O for their template engines of choice.
### Goals and Features
After building a half-dozen Express apps, I developed requirements and opinions about what a Handlebars view engine should provide and how it should be implemented. The following is that list:
* Add back the concept of "layout", which was removed in Express 3.x.
* Add back the concept of "partials" via Handlebars' partials mechanism.
* Support a directories of partials; e.g., `{{> foo/bar}}` which exists on the file system at `views/partials/foo/bar.handlebars`, by default.
* Smart file system I/O and template caching. When in development, templates are always loaded from disk. In production, raw files and compiled templates are cached, including partials.
* All async and non-blocking. File system I/O is slow and servers should not be blocked from handling requests while reading from disk. I/O queuing is used to avoid doing unnecessary work.
* Ability to easily precompiled templates and partials for use on the client, enabling template sharing and reuse.
* Ability to use a different Handlebars module/implementation other than the Handlebars npm package.
### Package Design
This package was designed to work great for both the simple and complex use cases. I _intentionally_ made sure the full implementation is exposed and is easily overridable.
The package exports a function which can be invoked with no arguments or with a `config` object and it will return a function (closed over sane defaults) which can be registered with an Express app. It's an engine factory function.
This exported engine factory has two properties which expose the underlying implementation:
* `ExpressHandlebars()`: The constructor function which holds the internal implementation on its `prototype`. This produces instance objects which store their configuration, `compiled` and `precompiled` templates, and expose an `engine()` function which can be registered with an Express app.
* `create()`: A convenience factory function for creating `ExpressHandlebars` instances.
An instance-based approach is used so that multiple `ExpressHandlebars` instances can be created with their own configuration, templates, partials, and helpers.
## Installation
Install using npm:
```shell
$ npm install express-handlebars
```
## Usage
This view engine uses sane defaults that leverage the "Express-way" of structuring an app's views. This makes it trivial to use in basic apps:
### Basic Usage
**Directory Structure:**
```
.
├── app.js
└── views
├── home.handlebars
└── layouts
└── main.handlebars
2 directories, 3 files
```
**app.js:**
Creates a super simple Express app which shows the basic way to register a Handlebars view engine using this package.
```javascript
var express = require('express');
var exphbs = require('express-handlebars');
var app = express();
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
app.set('view engine', 'handlebars');
app.get('/', function (req, res) {
res.render('home');
});
app.listen(3000);
```
**views/layouts/main.handlebars:**
The main layout is the HTML page wrapper which can be reused for the different views of the app. `{{{body}}}` is used as a placeholder for where the main content should be rendered.
```handlebars
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example App</title>
</head>
<body>
{{{body}}}
</body>
</html>
```
**views/home.handlebars:**
The content for the app's home view which will be rendered into the layout's `{{{body}}}`.
```handlebars
<h1>Example App: Home</h1>
```
#### Running the Example
The above example is bundled in this package's [examples directory][], where it can be run by:
```shell
$ cd examples/basic/
$ npm install
$ npm start
```
### Using Instances
Another way to use this view engine is to create an instance(s) of `ExpressHandlebars`, allowing access to the full API:
```javascript
var express = require('express');
var exphbs = require('express-handlebars');
var app = express();
var hbs = exphbs.create({ /* config */ });
// Register `hbs.engine` with the Express app.
app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');
// ...still have a reference to `hbs`, on which methods like `loadPartials()`
// can be called.
```
**Note:** The [Advanced Usage][] example demonstrates how `ExpressHandlebars` instances can be leveraged.
### Template Caching
This view engine uses a smart template caching strategy. In development, templates will always be loaded from disk, i.e., no caching. In production, raw files and compiled Handlebars templates are aggressively cached.
The easiest way to control template/view caching is through Express' [view cache setting][]:
```javascript
app.enable('view cache');
```
Express enables this setting by default when in production mode, i.e.:
```
process.env.NODE_ENV === "production"
```
**Note:** All of the public API methods accept `options.cache`, which gives control over caching when calling these methods directly.
### Layouts
A layout is simply a Handlebars template with a `{{{body}}}` placeholder. Usually it will be an HTML page wrapper into which views will be rendered.
This view engine adds back the concept of "layout", which was removed in Express 3.x. It can be configured with a path to the layouts directory, by default it's set to `"views/layouts/"`.
There are two ways to set a default layout: configuring the view engine's `defaultLayout` property, or setting [Express locals][] `app.locals.layout`.
The layout into which a view should be rendered can be overridden per-request by assigning a different value to the `layout` request local. The following will render the "home" view with no layout:
```javascript
app.get('/', function (req, res, next) {
res.render('home', {layout: false});
});
```
### Helpers
Helper functions, or "helpers" are functions that can be [registered with Handlebars][] and can be called within a template. Helpers can be used for transforming output, iterating over data, etc. To keep with the spirit of *logic-less* templates, helpers are the place where logic should be defined.
Handlebars ships with some [built-in helpers][], such as: `with`, `if`, `each`, etc. Most application will need to extend this set of helpers to include app-specific logic and transformations. Beyond defining global helpers on `Handlebars`, this view engine supports `ExpressHandlebars` instance-level helpers via the `helpers` configuration property, and render-level helpers via `options.helpers` when calling the `render()` and `renderView()` methods.
The following example shows helpers being specified at each level:
**app.js:**
Creates a super simple Express app which shows the basic way to register `ExpressHandlebars` instance-level helpers, and override one at the render-level.
```javascript
var express = require('express');
var exphbs = require('express-handlebars');
var app = express();
var hbs = exphbs.create({
// Specify helpers which are only registered on this instance.
helpers: {
foo: function () { return 'FOO!'; },
bar: function () { return 'BAR!'; }
}
});
app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');
app.get('/', function (req, res, next) {
res.render('home', {
showTitle: true,
// Override `foo` helper only for this rendering.
helpers: {
foo: function () { return 'foo.'; }
}
});
});
app.listen(3000);
```
**views/home.handlebars:**
The app's home view which uses helper functions to help render the contents.
```handlebars
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example App - Home</title>
</head>
<body>
<!-- Uses built-in `if` helper. -->
{{#if showTitle}}
<h1>Home</h1>
{{/if}}
<!-- Calls `foo` helper, overridden at render-level. -->
<p>{{foo}}</p>
<!-- Calls `bar` helper, defined at instance-level. -->
<p>{{bar}}</p>
</body>
</html>
```
#### More on Helpers
Refer to the [Handlebars website][] for more information on defining helpers:
* [Expression Helpers][]
* [Block Helpers][]
### Metadata
Handlebars has a data channel feature that propagates data through all scopes, including helpers and partials. Values in the data channel can be accessed via the `{{@variable}}` syntax. Express Handlebars provides metadata about a template it renders on a `{{@exphbs}}` object allowing access to things like the view name passed to `res.render()` via `{{@exphbs.view}}`.
The following is the list of metadata that's accessible on the `{{@exphbs}}` data object:
* `cache`: Boolean whether or not the template is cached.
* `view`: String name of the view passed to `res.render()`.
* `layout`: String name of the layout view.
* `data`: Original data object passed when rendering the template.
* `helpers`: Collection of helpers used when rendering the template.
* `partials`: Collection of partials used when rendering the template.
[examples directory]: https://github.com/ericf/express-handlebars/tree/master/examples
[view cache setting]: http://expressjs.com/api.html#app-settings
[Express locals]: http://expressjs.com/api.html#app.locals
[registered with Handlebars]: https://github.com/wycats/handlebars.js/#registering-helpers
[built-in helpers]: http://handlebarsjs.com/#builtins
[Handlebars website]: http://handlebarsjs.com/
[Expression Helpers]: http://handlebarsjs.com/expressions.html#helpers
[Block Helpers]: http://handlebarsjs.com/block_helpers.html
## API
### Configuration and Defaults
There are two main ways to use this package: via its engine factory function, or creating `ExpressHandlebars` instances; both use the same configuration properties and defaults.
```javascript
var exphbs = require('express-handlebars');
// Using the engine factory:
exphbs({ /* config */ });
// Create an instance:
exphbs.create({ /* config */ });
```
The following is the list of configuration properties and their default values (if any):
#### `handlebars=require('handlebars')`
The Handlebars module/implementation. This allows for the `ExpressHandlebars` instance to use a different Handlebars module/implementation than that provided by the Handlebars npm package.
#### `extname=".handlebars"`
The string name of the file extension used by the templates. This value should correspond with the `extname` under which this view engine is registered with Express when calling `app.engine()`.
The following example sets up an Express app to use `.hbs` as the file extension for views:
```javascript
var express = require('express');
var exphbs = require('express-handlebars');
var app = express();
app.engine('.hbs', exphbs({extname: '.hbs'}));
app.set('view engine', '.hbs');
```
**Note:** Setting the app's `"view engine"` setting will make that value the default file extension used for looking up views.
#### `layoutsDir="views/layouts/"`
The string path to the directory where the layout templates reside.
**Note:** If you configure Express to look for views in a custom location (e.g., `app.set('views', 'some/path/')`), you will need to reflect that by passing an updated path as the `layoutsDir` property in your configuration.
#### `partialsDir="views/partials/"`
The string path to the directory where the partials templates reside or object with the following properties:
* `dir`: The string path to the directory where the partials templates reside.
* `namespace`: Optional string namespace to prefix the partial names.
* `templates`: Optional collection (or promise of a collection) of templates in the form: `{filename: template}`.
**Note:** If you configure Express to look for views in a custom location (e.g., `app.set('views', 'some/path/')`), you will need to reflect that by passing an updated path as the `partialsDir` property in your configuration.
**Note:** Multiple partials dirs can be used by making `partialsDir` an array of strings, and/or config objects as described above. The namespacing feature is useful if multiple partials dirs are used and their file paths might clash.
#### `defaultLayout`
The string name or path of a template in the `layoutsDir` to use as the default layout. This is overridden by a `layout` specified in the app or response `locals`. **Note:** A falsy value will render without a layout; e.g., `res.render('home', {layout: false});`.
#### `helpers`
An object which holds the helper functions used when rendering templates with this `ExpressHandlebars` instance. When rendering a template, a collection of helpers will be generated by merging: `handlebars.helpers` (global), `helpers` (instance), and `options.helpers` (render-level). This allows Handlebars' `registerHelper()` function to operate as expected, will providing two extra levels over helper overrides.
#### `compilerOptions`
An object which holds options that will be passed along to the Handlebars compiler functions: `Handlebars.compile()` and `Handlebars.precompile()`.
### Properties
The public API properties are provided via `ExpressHandlebars` instances. In additional to the properties listed in the **Configuration and Defaults** section, the following are additional public properties:
#### `engine`
A function reference to the `renderView()` method which is bound to `this` `ExpressHandlebars` instance. This bound function should be used when registering this view engine with an Express app.
#### `extname`
The normalized `extname` which will _always_ start with `.` and defaults to `.handlebars`.
#### `compiled`
An object cache which holds compiled Handlebars template functions in the format: `{"path/to/template": [Function]}`.
#### `precompiled`
An object cache which holds precompiled Handlebars template strings in the format: `{"path/to/template": [String]}`.
### Methods
The following is the list of public API methods provided via `ExpressHandlebars` instances:
**Note:** All of the public methods return a [`Promise`][promise] (with the exception of `renderView()` which is the interface with Express.)
#### `getPartials([options])`
Retrieves the partials in the `partialsDir` and returns a Promise for an object mapping the partials in the form `{name: partial}`.
By default each partial will be a compiled Handlebars template function. Use `options.precompiled` to receive the partials as precompiled templates — this is useful for sharing templates with client code.
**Parameters:**
* `[options]`: Optional object containing any of the following properties:
* `[cache]`: Whether cached templates can be used if they have already been requested. This is recommended for production to avoid unnecessary file I/O.
* `[precompiled=false]`: Whether precompiled templates should be provided, instead of compiled Handlebars template functions.
The name of each partial corresponds to its location in `partialsDir`. For example, consider the following directory structure:
```
views
└── partials
├── foo
│   └── bar.handlebars
└── title.handlebars
2 directories, 2 files
```
`getPartials()` would produce the following result:
```javascript
var hbs = require('express-handlebars').create();
hbs.getPartials().then(function (partials) {
console.log(partials);
// => { 'foo/bar': [Function],
// => title: [Function] }
});
```
#### `getTemplate(filePath, [options])`
Retrieves the template at the specified `filePath` and returns a Promise for the compiled Handlebars template function.
Use `options.precompiled` to receive a precompiled Handlebars template.
**Parameters:**
* `filePath`: String path to the Handlebars template file.
* `[options]`: Optional object containing any of the following properties:
* `[cache]`: Whether a cached template can be used if it have already been requested. This is recommended for production to avoid necessary file I/O.
* `[precompiled=false]`: Whether a precompiled template should be provided, instead of a compiled Handlebars template function.
#### `getTemplates(dirPath, [options])`
Retrieves the all the templates in the specified `dirPath` and returns a Promise for an object mapping the compiled templates in the form `{filename: template}`.
Use `options.precompiled` to receive precompiled Handlebars templates — this is useful for sharing templates with client code.
**Parameters:**
* `dirPath`: String path to the directory containing Handlebars template files.
* `[options]`: Optional object containing any of the following properties:
* `[cache]`: Whether cached templates can be used if it have already been requested. This is recommended for production to avoid necessary file I/O.
* `[precompiled=false]`: Whether precompiled templates should be provided, instead of a compiled Handlebars template function.
#### `render(filePath, context, [options])`
Renders the template at the specified `filePath` with the `context`, using this instance's `helpers` and partials by default, and returns a Promise for the resulting string.
**Parameters:**
* `filePath`: String path to the Handlebars template file.
* `context`: Object in which the template will be executed. This contains all of the values to fill into the template.
* `[options]`: Optional object which can contain any of the following properties which affect this view engine's behavior:
* `[cache]`: Whether a cached template can be used if it have already been requested. This is recommended for production to avoid unnecessary file I/O.
* `[data]`: Optional object which can contain any data that Handlebars will pipe through the template, all helpers, and all partials. This is a side data channel.
* `[helpers]`: Render-level helpers that will be used instead of any instance-level helpers; these will be merged with (and will override) any global Handlebars helper functions.
* `[partials]`: Render-level partials that will be used instead of any instance-level partials. This is used internally as an optimization to avoid re-loading all the partials.
#### `renderView(viewPath, options|callback, [callback])`
Renders the template at the specified `viewPath` as the `{{{body}}}` within the layout specified by the `defaultLayout` or `options.layout`. Rendering will use this instance's `helpers` and partials, and passes the resulting string to the `callback`.
This method is called by Express and is the main entry point into this Express view engine implementation. It adds the concept of a "layout" and delegates rendering to the `render()` method.
The `options` will be used both as the context in which the Handlebars templates are rendered, and to signal this view engine on how it should behave, e.g., `options.cache=false` will load _always_ load the templates from disk.
**Parameters:**
* `viewPath`: String path to the Handlebars template file which should serve as the `{{{body}}}` when using a layout.
* `[options]`: Optional object which will serve as the context in which the Handlebars templates are rendered. It may also contain any of the following properties which affect this view engine's behavior:
* `[cache]`: Whether cached templates can be used if they have already been requested. This is recommended for production to avoid unnecessary file I/O.
* `[data]`: Optional object which can contain any data that Handlebars will pipe through the template, all helpers, and all partials. This is a side data channel.
* `[helpers]`: Render-level helpers that will be merged with (and will override) instance and global helper functions.
* `[partials]`: Render-level partials will be merged with (and will override) instance and global partials. This should be a `{partialName: fn}` hash or a Promise of an object with this shape.
* `[layout]`: Optional string path to the Handlebars template file to be used as the "layout". This overrides any `defaultLayout` value. Passing a falsy value will render with no layout (even if a `defaultLayout` is defined).
* `callback`: Function to call once the template is retrieved.
### Hooks
The following is the list of protected methods that are called internally and serve as _hooks_ to override functionality of `ExpressHandlebars` instances. A value or a promise can be returned from these methods which allows them to perform async operations.
#### `_compileTemplate(template, options)`
This hook will be called when a Handlebars template needs to be compiled. This function needs to return a compiled Handlebars template function, or a promise for one.
By default this hook calls `Handlebars.compile()`, but it can be overridden to preform operations before and/or after Handlebars compiles the template. This is useful if you wanted to first process Markdown within a Handlebars template.
**Parameters:**
* `template`: String Handlebars template that needs to be compiled.
* `options`: Object `compilerOptions` that were specified when the `ExpressHandlebars` instance as created. This object should be passed along to the `Handlebars.compile()` function.
#### `_precompileTemplate(template, options)`
This hook will be called when a Handlebars template needs to be precompiled. This function needs to return a serialized Handlebars template spec. string, or a promise for one.
By default this hook calls `Handlebars.precompile()`, but it can be overridden to preform operations before and/or after Handlebars precompiles the template. This is useful if you wanted to first process Markdown within a Handlebars template.
**Parameters:**
* `template`: String Handlebars template that needs to be precompiled.
* `options`: Object `compilerOptions` that were specified when the `ExpressHandlebars` instance as created. This object should be passed along to the `Handlebars.compile()` function.
#### `_renderTemplate(template, context, options)`
This hook will be called when a compiled Handlebars template needs to be rendered. This function needs to returned the rendered output string, or a promise for one.
By default this hook simply calls the passed-in `template` with the `context` and `options` arguments, but it can be overridden to perform operations before and/or after rendering the template.
**Parameters:**
* `template`: Compiled Handlebars template function to call.
* `context`: The context object in which to render the `template`.
* `options`: Object that contains options and metadata for rendering the template:
* `data`: Object to define custom `@variable` private variables.
* `helpers`: Object to provide custom helpers in addition to the globally defined helpers.
* `partials`: Object to provide custom partials in addition to the globally defined partials.
[promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
## Examples
### [Basic Usage][]
This example shows the most basic way to use this view engine.
### [Advanced Usage][]
This example is more comprehensive and shows how to use many of the features of this view engine, including helpers, partials, multiple layouts, etc.
As noted in the **Package Design** section, this view engine's implementation is instance-based, and more advanced usages can take advantage of this. The Advanced Usage example demonstrates how to use an `ExpressHandlebars` instance to share templates with the client, among other features.
[Basic Usage]: https://github.com/ericf/express-handlebars/tree/master/examples/basic
[Advanced Usage]: https://github.com/ericf/express-handlebars/tree/master/examples/advanced
License
-------
This software is free to use under the Yahoo! Inc. BSD license. See the [LICENSE file][] for license text and copyright information.
[LICENSE file]: https://github.com/ericf/express-handlebars/blob/master/LICENSE

23
node_modules/express-handlebars/index.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
/*
* Copyright (c) 2014, Yahoo Inc. All rights reserved.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
'use strict';
var ExpressHandlebars = require('./lib/express-handlebars');
exports = module.exports = exphbs;
exports.create = create;
exports.ExpressHandlebars = ExpressHandlebars;
// -----------------------------------------------------------------------------
function exphbs(config) {
return create(config).engine;
}
function create(config) {
return new ExpressHandlebars(config);
}

View File

@@ -0,0 +1,340 @@
/*
* Copyright (c) 2015, Yahoo Inc. All rights reserved.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
'use strict';
var Promise = global.Promise || require('promise');
var glob = require('glob');
var Handlebars = require('handlebars');
var fs = require('graceful-fs');
var path = require('path');
var utils = require('./utils');
module.exports = ExpressHandlebars;
// -----------------------------------------------------------------------------
function ExpressHandlebars(config) {
// Config properties with defaults.
utils.assign(this, {
handlebars : Handlebars,
extname : '.handlebars',
layoutsDir : 'views/layouts/',
partialsDir : 'views/partials/',
defaultLayout : undefined,
helpers : undefined,
compilerOptions: undefined,
}, config);
// Express view engine integration point.
this.engine = this.renderView.bind(this);
// Normalize `extname`.
if (this.extname.charAt(0) !== '.') {
this.extname = '.' + this.extname;
}
// Internal caches of compiled and precompiled templates.
this.compiled = Object.create(null);
this.precompiled = Object.create(null);
// Private internal file system cache.
this._fsCache = Object.create(null);
}
ExpressHandlebars.prototype.getPartials = function (options) {
var partialsDirs = Array.isArray(this.partialsDir) ?
this.partialsDir : [this.partialsDir];
partialsDirs = partialsDirs.map(function (dir) {
var dirPath;
var dirTemplates;
var dirNamespace;
// Support `partialsDir` collection with object entries that contain a
// templates promise and a namespace.
if (typeof dir === 'string') {
dirPath = dir;
} else if (typeof dir === 'object') {
dirTemplates = dir.templates;
dirNamespace = dir.namespace;
dirPath = dir.dir;
}
// We must have some path to templates, or templates themselves.
if (!(dirPath || dirTemplates)) {
throw new Error('A partials dir must be a string or config object');
}
// Make sure we're have a promise for the templates.
var templatesPromise = dirTemplates ? Promise.resolve(dirTemplates) :
this.getTemplates(dirPath, options);
return templatesPromise.then(function (templates) {
return {
templates: templates,
namespace: dirNamespace,
};
});
}, this);
return Promise.all(partialsDirs).then(function (dirs) {
var getTemplateName = this._getTemplateName.bind(this);
return dirs.reduce(function (partials, dir) {
var templates = dir.templates;
var namespace = dir.namespace;
var filePaths = Object.keys(templates);
filePaths.forEach(function (filePath) {
var partialName = getTemplateName(filePath, namespace);
partials[partialName] = templates[filePath];
});
return partials;
}, {});
}.bind(this));
};
ExpressHandlebars.prototype.getTemplate = function (filePath, options) {
filePath = path.resolve(filePath);
options || (options = {});
var precompiled = options.precompiled;
var cache = precompiled ? this.precompiled : this.compiled;
var template = options.cache && cache[filePath];
if (template) {
return template;
}
// Optimistically cache template promise to reduce file system I/O, but
// remove from cache if there was a problem.
template = cache[filePath] = this._getFile(filePath, {cache: options.cache})
.then(function (file) {
if (precompiled) {
return this._precompileTemplate(file, this.compilerOptions);
}
return this._compileTemplate(file, this.compilerOptions);
}.bind(this));
return template.catch(function (err) {
delete cache[filePath];
throw err;
});
};
ExpressHandlebars.prototype.getTemplates = function (dirPath, options) {
options || (options = {});
var cache = options.cache;
return this._getDir(dirPath, {cache: cache}).then(function (filePaths) {
var templates = filePaths.map(function (filePath) {
return this.getTemplate(path.join(dirPath, filePath), options);
}, this);
return Promise.all(templates).then(function (templates) {
return filePaths.reduce(function (hash, filePath, i) {
hash[filePath] = templates[i];
return hash;
}, {});
});
}.bind(this));
};
ExpressHandlebars.prototype.render = function (filePath, context, options) {
options || (options = {});
return Promise.all([
this.getTemplate(filePath, {cache: options.cache}),
options.partials || this.getPartials({cache: options.cache}),
]).then(function (templates) {
var template = templates[0];
var partials = templates[1];
var helpers = options.helpers || this.helpers;
// Add ExpressHandlebars metadata to the data channel so that it's
// accessible within the templates and helpers, namespaced under:
// `@exphbs.*`
var data = utils.assign({}, options.data, {
exphbs: utils.assign({}, options, {
filePath: filePath,
helpers : helpers,
partials: partials,
}),
});
return this._renderTemplate(template, context, {
data : data,
helpers : helpers,
partials: partials,
});
}.bind(this));
};
ExpressHandlebars.prototype.renderView = function (viewPath, options, callback) {
options || (options = {});
var context = options;
// Express provides `settings.views` which is the path to the views dir that
// the developer set on the Express app. When this value exists, it's used
// to compute the view's name.
var view;
var viewsPath = options.settings && options.settings.views;
if (viewsPath) {
view = this._getTemplateName(path.relative(viewsPath, viewPath));
}
// Merge render-level and instance-level helpers together.
var helpers = utils.assign({}, this.helpers, options.helpers);
// Merge render-level and instance-level partials together.
var partials = Promise.all([
this.getPartials({cache: options.cache}),
Promise.resolve(options.partials),
]).then(function (partials) {
return utils.assign.apply(null, [{}].concat(partials));
});
// Pluck-out ExpressHandlebars-specific options and Handlebars-specific
// rendering options.
options = {
cache : options.cache,
view : view,
layout: 'layout' in options ? options.layout : this.defaultLayout,
data : options.data,
helpers : helpers,
partials: partials,
};
this.render(viewPath, context, options)
.then(function (body) {
var layoutPath = this._resolveLayoutPath(options.layout);
if (layoutPath) {
return this.render(
layoutPath,
utils.assign({}, context, {body: body}),
utils.assign({}, options, {layout: undefined})
);
}
return body;
}.bind(this))
.then(utils.passValue(callback))
.catch(utils.passError(callback));
};
// -- Protected Hooks ----------------------------------------------------------
ExpressHandlebars.prototype._compileTemplate = function (template, options) {
return this.handlebars.compile(template, options);
};
ExpressHandlebars.prototype._precompileTemplate = function (template, options) {
return this.handlebars.precompile(template, options);
};
ExpressHandlebars.prototype._renderTemplate = function (template, context, options) {
return template(context, options);
};
// -- Private ------------------------------------------------------------------
ExpressHandlebars.prototype._getDir = function (dirPath, options) {
dirPath = path.resolve(dirPath);
options || (options = {});
var cache = this._fsCache;
var dir = options.cache && cache[dirPath];
if (dir) {
return dir.then(function (dir) {
return dir.concat();
});
}
var pattern = '**/*' + this.extname;
// Optimistically cache dir promise to reduce file system I/O, but remove
// from cache if there was a problem.
dir = cache[dirPath] = new Promise(function (resolve, reject) {
glob(pattern, {
cwd : dirPath,
follow: true
}, function (err, dir) {
if (err) {
reject(err);
} else {
resolve(dir);
}
});
});
return dir.then(function (dir) {
return dir.concat();
}).catch(function (err) {
delete cache[dirPath];
throw err;
});
};
ExpressHandlebars.prototype._getFile = function (filePath, options) {
filePath = path.resolve(filePath);
options || (options = {});
var cache = this._fsCache;
var file = options.cache && cache[filePath];
if (file) {
return file;
}
// Optimistically cache file promise to reduce file system I/O, but remove
// from cache if there was a problem.
file = cache[filePath] = new Promise(function (resolve, reject) {
fs.readFile(filePath, 'utf8', function (err, file) {
if (err) {
reject(err);
} else {
resolve(file);
}
});
});
return file.catch(function (err) {
delete cache[filePath];
throw err;
});
};
ExpressHandlebars.prototype._getTemplateName = function (filePath, namespace) {
var extRegex = new RegExp(this.extname + '$');
var name = filePath.replace(extRegex, '');
if (namespace) {
name = namespace + '/' + name;
}
return name;
};
ExpressHandlebars.prototype._resolveLayoutPath = function (layoutPath) {
if (!layoutPath) {
return null;
}
if (!path.extname(layoutPath)) {
layoutPath += this.extname;
}
return path.resolve(this.layoutsDir, layoutPath);
};

29
node_modules/express-handlebars/lib/utils.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2014, Yahoo Inc. All rights reserved.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
'use strict';
exports.assign = Object.assign || require('object.assign');
exports.passError = passError;
exports.passValue = passValue;
// -----------------------------------------------------------------------------
function passError(callback) {
return function (reason) {
setImmediate(function () {
callback(reason);
});
};
}
function passValue(callback) {
return function (value) {
setImmediate(function () {
callback(null, value);
});
};
}

96
node_modules/express-handlebars/package.json generated vendored Normal file
View File

@@ -0,0 +1,96 @@
{
"_args": [
[
"express-handlebars",
"/home/beppe/Github/yahooApi"
]
],
"_from": "express-handlebars@latest",
"_id": "express-handlebars@3.0.0",
"_inCache": true,
"_installable": true,
"_location": "/express-handlebars",
"_npmUser": {
"email": "sakhat@gmail.com",
"name": "sahat"
},
"_npmVersion": "1.4.29",
"_phantomChildren": {},
"_requested": {
"name": "express-handlebars",
"raw": "express-handlebars",
"rawSpec": "",
"scope": null,
"spec": "latest",
"type": "tag"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/express-handlebars/-/express-handlebars-3.0.0.tgz",
"_shasum": "80a070bb819b09e4af2ca6d0780f75ce05e75c2f",
"_shrinkwrap": null,
"_spec": "express-handlebars",
"_where": "/home/beppe/Github/yahooApi",
"author": {
"email": "eferraiuolo@gmail.com",
"name": "Eric Ferraiuolo",
"url": "http://ericf.me/"
},
"bugs": {
"url": "https://github.com/ericf/express-handlebars/issues"
},
"dependencies": {
"glob": "^6.0.4",
"graceful-fs": "^4.1.2",
"handlebars": "^4.0.5",
"object.assign": "^4.0.3",
"promise": "^7.0.0"
},
"description": "A Handlebars view engine for Express which doesn't suck.",
"devDependencies": {},
"directories": {
"example": "examples"
},
"dist": {
"shasum": "80a070bb819b09e4af2ca6d0780f75ce05e75c2f",
"tarball": "https://registry.npmjs.org/express-handlebars/-/express-handlebars-3.0.0.tgz"
},
"engines": {
"node": ">=0.10"
},
"gitHead": "a7076983c39916a6525c244a8e3a39638759a318",
"homepage": "https://github.com/ericf/express-handlebars",
"keywords": [
"express",
"express3",
"handlebars",
"layout",
"partials",
"templates",
"view"
],
"license": "BSD-3-Clause",
"main": "index.js",
"maintainers": [
{
"name": "ericf",
"email": "eferraiuolo@gmail.com"
},
{
"name": "sahat",
"email": "sakhat@gmail.com"
}
],
"name": "express-handlebars",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/ericf/express-handlebars.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "3.0.0"
}