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

Allow user to use DB-values inside blogpost #79

Open
ThomasTJdev opened this issue Mar 17, 2019 · 1 comment
Open

Allow user to use DB-values inside blogpost #79

ThomasTJdev opened this issue Mar 17, 2019 · 1 comment
Labels
question Further information is requested

Comments

@ThomasTJdev
Copy link
Owner

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

@ThomasTJdev ThomasTJdev added the question Further information is requested label Mar 17, 2019
@juancarlospaco
Copy link
Collaborator

Use a Template instead of a Route ❔
See my implementation here for similar (but not same) kinda thing:
#80 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants