Skip to content

Allow user to use DB-values inside blogpost #79

Description

@ThomasTJdev

When writing a blogpost, the user has full control on what to show - HTML, CSS and JS. But what if the user want's to access data from the database, e.g. inserting the blog posts publication date just beneath the blog post heading?

Proposal:

Define certain strings, which would be replaced on rendering.

Problems:

It is to my knowledge not possible to query a string from the DB and execute Nim-code within it.

Suggestion:

I can't seem to find an elegant solution to this, so my proposal is:

  1. Prepare a multiReplace() on the queried string from the DB with certain elements such as publication date, views, category.

Example

# user edits a blog post from the browser interface
<div id="mainContainer" class="blogpost">
  <h1>New blog</h1>
  <div>${category}</div>
  <div>${views}</div>
<div>
# routes
get "/blog/newblogpage":
  let data = query-DB-to-fetch-data()
  resp data.multiReplace([("${category}", "Cats"), ("${views}", viewCount)])

Before

before

After

new

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions