This repository has been archived by the owner on Jul 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f190a7
commit 80f4f40
Showing
2 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
declare module '@atlas.js/templates' { | ||
import AtlasAction from '@atlas.js/action' | ||
|
||
/** | ||
* This component allows you to render a wide range of templating languages into the final HTML | ||
* | ||
* Under the hood, the [_consolidate.js_](https://github.com/tj/consolidate.js) project is used | ||
* for the actual rendering, so any template language supported by that project is also supported | ||
* here. | ||
*/ | ||
class Action extends AtlasAction { | ||
/** Action runtime configuration values */ | ||
config: Action.Config | ||
|
||
/** | ||
* Render a template with the specified name into HTML | ||
* | ||
* The template name must match the template's filename, relative to the location of the | ||
* templates directory specified in this component's configuration. | ||
* | ||
* @param template The template's filename, relative to the templates' directory | ||
* @param locals Optional variables to be provided to the template | ||
* @return {Promise<string>} The rendered HTML string | ||
*/ | ||
render(template: string, locals?: object): Promise<string> | ||
} | ||
|
||
namespace Action { | ||
/** Configuration schema available to this action */ | ||
interface Config { | ||
/** | ||
* Filesystem location, relative to `atlas.root`, where the templates are located | ||
* @default templates | ||
*/ | ||
templates?: string | ||
|
||
/** | ||
* File extension to look for when resolving template names into actual files | ||
* @default .pug | ||
*/ | ||
extension?: string | ||
|
||
/** | ||
* Templating engine to use | ||
* | ||
* @see https://github.com/tj/consolidate.js for supported languages | ||
* @default pug | ||
*/ | ||
engine?: string | ||
|
||
/** | ||
* Local values to be passed directly to the rendering engine as variable replacements | ||
*/ | ||
locals?: { | ||
/** | ||
* Some engines support various caching strategies. Set this to `false` to disable this. | ||
* | ||
* @see https://github.com/tj/consolidate.js#caching | ||
* @default true | ||
*/ | ||
cache?: boolean | ||
[key: string]: any | ||
} | ||
} | ||
} | ||
|
||
export { | ||
Action, | ||
} | ||
} |