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.

55 lines
2.3 KiB

  1. # Text Plugin for DocPad
  2. This plugin allows you to render variables within `templateData` using text elements
  3. E.g. if you have this in your `docpad.cson`
  4. ``` coffeescript
  5. {
  6. templateData:
  7. firstname: 'Benjamin'
  8. lastname: 'Lupton'
  9. fullname: '<t>firstname</t> <t>lastname</t>'
  10. markdownExample: '<t render="markdown">this is so **awesome**</t>'
  11. markdownEcoExample: '<t render="md.eco">here is a random number: **<%- Math.random() %>**</t>'
  12. }
  13. ```
  14. Doing the following inside a document:
  15. ``` html
  16. My creator's firstname is: <t>firstname</t>
  17. My creator's lastname is: <t>lastname</t>
  18. My creator's fullname is: <t>fullname</t>
  19. The markdown example is: <t>markdownExample</t>
  20. The markdown eco example is: <t>markdownEcoExample</t>
  21. ```
  22. Will output:
  23. ``` html
  24. My creator's firstname is: Benjamin
  25. My creator's lastname is: Lupton
  26. My creator's fullname is: Benjamin Lupton
  27. The markdown example is: this is so <strong>awesome</strong>
  28. The markdown eco example is: here is a random number: <strong>0.5123213213123</strong>
  29. ```
  30. 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.
  31. If you are embedding a text block into a text block, it is best that you name your text block like so `<t:myName>blah</t:myName>` that way our parser won't get confused as easily :)
  32. 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).
  33. Alternatively, you can use the `t` template helper like so `@t('*markdown*', {render="markdown"})`
  34. ## Install
  35. To use this plugin with DocPad, simply run `npm install docpad-plugin-text` inside your website's directory. You'd probably also want to add `"docpad-plugin-text": "latest"` to your `package.json` dependencies.
  36. ## History
  37. You can discover the history inside the `History.md` file
  38. ## License
  39. Licensed under the incredibly [permissive](http://en.wikipedia.org/wiki/Permissive_free_software_licence) [MIT License](http://creativecommons.org/licenses/MIT/)
  40. <br/>Copyright &copy; 2012+ [Bevry Pty Ltd](http://bevry.me)