https://github.com/justeat/f-templates
Locate, compile, and serve HTML from templates.
https://github.com/justeat/f-templates
fozzie ui
Last synced: 3 months ago
JSON representation
Locate, compile, and serve HTML from templates.
- Host: GitHub
- URL: https://github.com/justeat/f-templates
- Owner: justeat
- License: other
- Created: 2018-01-03T16:18:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-03T15:39:41.000Z (over 5 years ago)
- Last Synced: 2025-02-09T08:48:03.376Z (3 months ago)
- Topics: fozzie, ui
- Language: JavaScript
- Size: 608 KB
- Stars: 1
- Watchers: 38
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# `f-templates` :bear:
[](https://badge.fury.io/js/%40justeat%2Ff-templates)
[](https://travis-ci.org/justeat/f-templates)## About
The purpose of this module is to copy a JavaScript module into your web project which can
locate, compile, and serve HTML from templates. This is achieved by using the [gulp-build-fozzie `copy:assets`](https://github.com/justeat/gulp-build-fozzie#copyassets) task.## Adding `f-templates` to your project
Add the module to your dependencies
```bash
yarn add @justeat/f-templates
```Once the module has been copied into your project (via the [gulp-build-fozzie `copy:assets`](https://github.com/justeat/gulp-build-fozzie#copyassets) task) you can use it in the following ways.
### Node
Require and call the imported module:
```js
const templates = require('./templates');const html = templates.getTemplate(callback, moduleName, language, options);
```### .Net Core
If you are using the [NodeServices NuGet package](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.NodeServices#microsoftaspnetcorenodeservices) then you can call it like this:
```csharp
public async Task MyAction([FromServices] INodeServices nodeServices)
{
var result = await nodeServices.InvokeExportAsync("./templates", getTemplate, templateName, language, options);
return new HtmlString(result);
}
```## Parameters
- `callback` is a function which should be called upon completion. This is not required when using NodeServices in .Net Core.
- `moduleName` is the name of the template file which you would should be used to generate the HTML.
- `language` is a string containing the country code for the language you'd like the templates to compile with e.g. "fr-CA" for French Canadian.
- `options` is an optional parameter in which you can pass parameters which will be used in the template.