A semantic search engine for source code https://bitshift.benkurtovic.com/
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.

1234567891011121314151617181920212223242526
  1. """
  2. :synopsis: Helper functions for use inside the project's Jinja templates.
  3. """
  4. from flask import Markup
  5. ASSET_HTML_TEMPLATES = {
  6. 'css': "<link rel='stylesheet' type='text/css' href='/static/css/%s'>",
  7. 'js': "<script src='/static/js/%s'></script>"
  8. }
  9. def tag(filename):
  10. """
  11. Generate an HTML tag for a CSS/JS asset, based on its file extension.
  12. :param filename: The filename of the asset to create a tag for.
  13. :type filename: str
  14. :return: A string containing a `<source>` tag for JS files, and a `<link>`
  15. for CSS files.
  16. :rtype: str
  17. """
  18. file_ext = filename.split(".")[-1]
  19. return Markup(ASSET_HTML_TEMPLATES[file_ext] % filename)