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.

66 lines
3.4 KiB

  1. # Text Plugin for [DocPad](http://docpad.org)
  2. [![Build Status](https://secure.travis-ci.org/docpad/docpad-plugin-text.png?branch=master)](http://travis-ci.org/docpad/docpad-plugin-text "Check this project's build status on TravisCI")
  3. [![NPM version](https://badge.fury.io/js/docpad-plugin-text.png)](https://npmjs.org/package/docpad-plugin-text "View this project on NPM")
  4. [![Flattr donate button](https://raw.github.com/balupton/flattr-buttons/master/badge-89x18.gif)](http://flattr.com/thing/344188/balupton-on-Flattr "Donate monthly to this project using Flattr")
  5. [![PayPayl donate button](https://www.paypalobjects.com/en_AU/i/btn/btn_donate_SM.gif)](https://www.paypal.com/au/cgi-bin/webscr?cmd=_flow&SESSION=IHj3DG3oy_N9A9ZDIUnPksOi59v0i-EWDTunfmDrmU38Tuohg_xQTx0xcjq&dispatch=5885d80a13c0db1f8e263663d3faee8d14f86393d55a810282b64afed84968ec "Donate once-off to this project using Paypal")
  6. This plugin allows you to render variables within `templateData` using text elements
  7. E.g. if you have this in your `docpad.cson`
  8. ``` coffeescript
  9. {
  10. templateData:
  11. firstname: 'Benjamin'
  12. lastname: 'Lupton'
  13. fullname: '<t>firstname</t> <t>lastname</t>'
  14. markdownExample: '<t render="markdown">this is so **awesome**</t>'
  15. markdownEcoExample: '<t render="md.eco">here is a random number: **<%- Math.random() %>**</t>'
  16. }
  17. ```
  18. Doing the following inside a document:
  19. ``` html
  20. My creator's firstname is: <t>firstname</t>
  21. My creator's lastname is: <t>lastname</t>
  22. My creator's fullname is: <t>fullname</t>
  23. The markdown example is: <t>markdownExample</t>
  24. The markdown eco example is: <t>markdownEcoExample</t>
  25. ```
  26. Will output:
  27. ``` html
  28. My creator's firstname is: Benjamin
  29. My creator's lastname is: Lupton
  30. My creator's fullname is: Benjamin Lupton
  31. The markdown example is: this is so <strong>awesome</strong>
  32. The markdown eco example is: here is a random number: <strong>0.5123213213123</strong>
  33. ```
  34. 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.
  35. 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 :)
  36. 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).
  37. Alternatively, you can use the `t` template helper like so `@t('*markdown*', {render="markdown"})`
  38. ## Install
  39. 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.
  40. ## History
  41. [You can discover the history inside the `History.md` file](https://github.com/bevry/docpad-plugin-text/blob/master/History.md#files)
  42. ## Contributing
  43. [You can discover the contributing instructions inside the `Contributing.md` file](https://github.com/bevry/docpad-plugin-text/blob/master/Contributing.md#files)
  44. ## License
  45. Licensed under the incredibly [permissive](http://en.wikipedia.org/wiki/Permissive_free_software_licence) [MIT License](http://creativecommons.org/licenses/MIT/)
  46. <br/>Copyright &copy; 2012+ [Bevry Pty Ltd](http://bevry.me) <us@bevry.me>