Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/docpad/docpad-plugin-text
Allows you to render templateData with HTML elements
https://github.com/docpad/docpad-plugin-text
docpad-plugin
Last synced: 2 months ago
JSON representation
Allows you to render templateData with HTML elements
- Host: GitHub
- URL: https://github.com/docpad/docpad-plugin-text
- Owner: docpad
- License: other
- Created: 2012-10-17T11:40:50.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2024-02-11T00:07:15.000Z (11 months ago)
- Last Synced: 2024-11-02T03:35:22.431Z (2 months ago)
- Topics: docpad-plugin
- Language: JavaScript
- Homepage:
- Size: 254 KB
- Stars: 7
- Watchers: 16
- Forks: 5
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
Text Plugin for DocPad
Allows you to render variables within `templateData` using text elements
## Usage
If you have this in your `docpad.cson`
```coffeescript
{
templateData:
firstname: 'Benjamin'
lastname: 'Lupton'
fullname: 'firstname lastname'
markdownExample: 'this is so **awesome**'
markdownEcoExample: 'here is a random number: **<%- Math.random() %>**'
}
```Doing the following inside a document:
```html
My creator's firstname is: firstname My creator's lastname is:
lastname My creator's fullname is: fullname The markdown example
is: markdownExample The markdown eco example is:
markdownEcoExample
```Will output:
```html
My creator's firstname is: Benjamin My creator's lastname is: Lupton My
creator's fullname is: Benjamin Lupton The markdown example is: this is so
awesome The markdown eco example is: here is a random number:
0.5123213213123
```Which is incredibly useful for abstracting out common generic pieces of text from your templates and placing them inside your configuration files. A common use case for this is easy configurability of skeletons, as well as easier translation of your website.
If you are embedding a text block into a text block, it is best that you name your text block like so `blah` that way our parser won't get confused as easily :)
To use it with [coffeekup](http://coffeekup.org/) you'll do it like so `tag 'text', {render:"md"}, "your **markdown** content"`. [More info here.](https://github.com/bevry/docpad/issues/194#issuecomment-11363441).
Alternatively, you can use the `t` template helper like so `@t('*markdown*', {render:"markdown"})`
## Configuration
### `matchElementRegexString` defaults to `'t(?:ext)?'`
What regex string should we use to find text elements. The default value will find `` and `` elements. If you use SVG, you may want to change this just to `t` to avoid [conflicts with the `text` element.](https://github.com/docpad/docpad-plugin-text/issues/4)
### `preferredElement` defualts to `'t'`
What element should be preferred when we are inject text elements with the `t` template helper? The default value will inject `` elements.
Install
Install this DocPad plugin by entering
docpad install text
into your terminal.History
Discover the release history by heading on over to the
HISTORY.md
file.Contribute
Discover how you can contribute by heading on over to the
CONTRIBUTING.md
file.Backers
Maintainers
These amazing people are maintaining this project:
Sponsors
No sponsors yet! Will you be the first?
Contributors
These amazing people have contributed code to this project:
-
Benjamin Lupton — view contributions -
Daniel Cohen — view contributions -
Jeff Barczewski — view contributions
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
License
Unless stated otherwise all works are:
- Copyright © 2012+ Bevry Pty Ltd
and licensed under: