A semantic search engine for source code https://bitshift.benkurtovic.com/
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

24 righe
645 B

  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. :return: A string containing a `<source>` tag for JS files, and a `<link>`
  14. for CSS files.
  15. """
  16. file_ext = filename.split(".")[-1]
  17. return Markup(ASSET_HTML_TEMPLATES[file_ext] % filename)