Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement a more idiomatic (HTML) templating solution #1133

Open
thescientist13 opened this issue Aug 3, 2023 · 0 comments
Open

implement a more idiomatic (HTML) templating solution #1133

thescientist13 opened this issue Aug 3, 2023 · 0 comments
Assignees
Labels
CLI enhancement Improve something existing (e.g. no docs, new APIs, etc)
Milestone

Comments

@thescientist13
Copy link
Member

Type of Change

Enhancement

Summary

Coming out of #1126 , it's clear that how Greenwood handles various aspects of its templating, primarily for HTML, is a little too naive / brittle.

For example, Greenwood uses placeholders for injecting content into an HTML template

<html>
  <body>
    <content-outlet><content-outlet>
  </body>
</html>

Would get handled like this in the CLI

body = body.replace(/\<content-outlet>(.*)<\/content-outlet>/s, processedMarkdown.contents);

This issue is that $1 is used for matching when used in conjunction with the String .replace function.

So we have to keep doing things like

body = body.replace(/\<content-outlet>(.*)<\/content-outlet>/s, processedMarkdown.contents.replace(/\$/g, '$$$'));

Details

So rather than keep suffering through these issues...

Since we are already using an HTML parser, I see it supports methods like set_content which could a much more practical way to approach this problem.

So basically any usage of .replace, for HTML at minimum, would be a candidate for refactoring.

@thescientist13 thescientist13 added enhancement Improve something existing (e.g. no docs, new APIs, etc) CLI labels Aug 3, 2023
@thescientist13 thescientist13 added this to the 1.0 milestone Aug 3, 2023
@thescientist13 thescientist13 self-assigned this Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI enhancement Improve something existing (e.g. no docs, new APIs, etc)
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant