Просмотр исходного кода

send template tag data to view

yusuketk 7 лет назад
Родитель
Сommit
4485c7b46b
2 измененных файлов с 11 добавлено и 6 удалено
  1. 4 2
      src/server/models/page.js
  2. 7 4
      src/server/routes/page.js

+ 4 - 2
src/server/models/page.js

@@ -916,7 +916,7 @@ module.exports = function(crowi) {
     return assignDecendantsTemplate(decendantsTemplates, newPath);
   };
 
-  const fetchTemplate = (templates, templatePath) => {
+  const fetchTemplate = async(templates, templatePath) => {
     let templateBody;
     /**
      * get children template
@@ -937,7 +937,9 @@ module.exports = function(crowi) {
       templateBody = decendantsTemplate.revision.body;
     }
 
-    return templateBody;
+    const templateTags = await templates[0].getRelatedTagsById();
+
+    return { templateBody, templateTags };
   };
 
   /**

+ 7 - 4
src/server/routes/page.js

@@ -416,10 +416,13 @@ module.exports = function(crowi, app) {
       view = 'customlayout-selector/not_found';
 
       // retrieve templates
-      let template = await Page.findTemplate(path);
+      const template = await Page.findTemplate(path);
+
       if (template != null) {
-        template = replacePlaceholdersOfTemplate(template, req);
-        renderVars.template = template;
+        const body = replacePlaceholdersOfTemplate(template.templateBody, req);
+        const tags = template.templateTags;
+        renderVars.template = body;
+        renderVars.templateTags = tags;
       }
 
       // add scope variables by ancestor page
@@ -433,7 +436,7 @@ module.exports = function(crowi, app) {
     const limit = 50;
     const offset = parseInt(req.query.offset) || 0;
     await addRenderVarsForDescendants(renderVars, path, req.user, offset, limit, true);
-
+console.log(renderVars);
     return res.render(view, renderVars);
   };