generic.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. """
  2. Generic Tag
  3. -----------
  4. This implements a tag that that is mostly useful for testing.
  5. This tag does not implement anything useful, but is a place that can be
  6. used for testing liquid_tags infrastructure, in situations that need
  7. a full lifecycle test.
  8. The first use case is a test of a tag that will pull out data from
  9. the configuration file and make it available during the test.
  10. A tag of
  11. {% generic config <config file variable> %>
  12. will be replaced with the value of that config file in html
  13. Not all config file variables are exposed - the set
  14. of variables are from the LIQUID_CONFIGS setting, which is a list of
  15. variables to pass to the liquid tags.
  16. """
  17. from .mdx_liquid_tags import LiquidTags
  18. @LiquidTags.register('generic')
  19. def generic(preprocessor, tag, markup):
  20. (cmd, args) = markup.split(' ', 1)
  21. if cmd.lower() == 'config':
  22. config_param = args.split()[0].upper()
  23. config_val = preprocessor.configs.getConfig(config_param)
  24. return(config_val)
  25. else:
  26. return 'generic: %s ' % markup
  27. #----------------------------------------------------------------------
  28. # This import allows image tag to be a Pelican plugin
  29. from liquid_tags import register