Anonymous avatar Anonymous committed 8356590

added base path to template vars

Comments (0)

Files changed (2)


             ttxt =
             template = Template(ttxt)
-            string = template.substitute(templatedict(env), __content__=string)
+            string = template.substitute(templatedict(env['template-vars']), __content__=string)
             return string
     def _process_string(self, string, env):
+        basepath = nom.config.base_url
+        if basepath.startswith('http://'):
+            basepath = '/' + basepath[7:].partition('/')[2]
+        env.setdefault('template-vars', {})['basepath'] = basepath
         # dirt simple search heuristic
-        base = basename(splitext(env.get('input-filename', ''))[0])
+        stem = basename(splitext(env.get('input-filename', ''))[0])
         # This belongs elsewhere, in a separate title/slugline
         # generator plugin
-        env.setdefault('title', base.replace('_', ' ').capitalize())
+        env.setdefault('title', stem.replace('_', ' ').capitalize())
-        path = self._search_template_path(base, env)
+        path = self._search_template_path(stem, env)
         if path:
             string = self._render_template(path, string, env)


-  <link rel="stylesheet" href="/nomtest/highlight.css" media="screen, print">
+  <link rel="stylesheet" href="${basepath}/highlight.css" media="screen, print">
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.