Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ see wiki for more information: [wiki](https://github.com/thmarx/cms/wiki)

# changelog

## 7.8.0

* **BUG** Namespaces not set when executing content pipeline [#416](https://github.com/CondationCMS/cms-server/pull/416)

## 7.7.0

* **FEATURE** TemplateEngineFeature for scripts [#393](https://github.com/CondationCMS/cms-server/pull/393)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/

import com.condation.cms.api.db.ContentNode;
import com.condation.cms.api.db.cms.ReadOnlyFile;
import com.condation.cms.api.request.RequestContext;
Expand All @@ -36,22 +35,31 @@
* @author thmar
*/
public interface TemplateEngine {

public void invalidateCache();

void updateTheme (Theme theme);
void updateTheme(Theme theme);

String render(final String template, final TemplateEngine.Model model) throws IOException;

default String renderFromString(final String templateString, final TemplateEngine.Model model) throws IOException {
return templateString;
}

@RequiredArgsConstructor
public static class Model {

public final Map<String, Object> values = new HashMap<>();
public final ReadOnlyFile contentFile;
public final ContentNode contentNode;
public final RequestContext requestContext;
}

public Model copy() {
var copy = new Model(this.contentFile, this.contentNode, this.requestContext);

copy.values.putAll(this.values);

return copy;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ public String render(final ReadOnlyFile contentFile, final RequestContext contex

extendModel(model, namespace);

String content = renderContent(rawContent, context, model);
var modelCopy = model.copy();
modelCopy.values.putAll(namespace.getNamespaces());

String content = renderContent(rawContent, context, modelCopy);
model.values.put("content", content);
namespace.add("node", "content", content);

Expand Down