Content processing with shortcodes

Shortcodes are probably the most powerful tool to process Markdown content inline.

A corner stone

They are simple to create and use, almost anything can be done with them, and they represent an important opportunity that should not be missed. Eleventy has two kinds of shortcode:

{% _shortcode_id "argument" %}

{% _shortcode_id %}... Content to be processed ...{% end_shortcode_id %}

11tyTips doesn’t use a lot of shortcodes, but they are essential to its content. Let’s dissect the most omnipresent of it: the _code_block paired shortcode. It is passed to Eleventy configuration method addPairedShortcode this way:

make_o.addPairedShortcode('_code_block', content_s => CODES_o.code_block__s( content_s ) )

Here, _code_block is the shortcode identifier 11tyTips uses a leading underscore character because the shortcode closing tag adds the word end before the shortcode identifier: end_shortcode is more readable than endshortcode, isn’t it?

Shortcode anatomy (to be continued...)

Comments

Home

Github

Twitter

RSS

All tips

  1. ...1 Site structure Site structure and directories
  2. ...2 Cloning 11tyTips site Start bloging with a clean site structure
  3. ...3 Source tree A bird's-eye view of the site
  4. ...4 Eleventy settings The main components of an Eleventy site build
  5. ...5 Global settings Global data for frequent use
  6. ...6 Styles guide Styles listing
  7. ...7 Names guide How variable identifiers are forged
  8. ...8 Front matter Accessing front matter data in Markdown and templates
  9. ...9 Shortcodes Processing Markdown content with shortcodes
  10. ..10 Minifying styles and script Generate minified CSS and JavaScript as inline blocks or files
  11. ..11 Using shorthands Use shorthand notation to simplify and clean your markdown
  12. ..12 Front matter post processing function A front matter function can be invoqued to modify the global or partial output of the template engine
  13. ..13 Processing before and after the template engine Add any kind of processing before and after your templating engine has done its work
  14. ..14 Variables scope and templates inheritance Take care of scope rules when using template inheritance
  15. ..15 Creating a menu A smart menu of posts is hard to create
  16. ..16 CSS mixins Filters ala SASS
  17. ..17 Light(ning) images How to slim overweight images