guyht / Glog

NodeJS and Git backed blogging engine
MIT License
52 stars 10 forks source link

Passing variables to the templates #28

Open guyht opened 11 years ago

guyht commented 11 years ago

/cc @wlaurance

Currently, introducing new variables into the template can only be done by editing the Glog core code. I would like to propose a change to allow users to:

This could be achieved by adding a 'user' section to the config file e.g.

{
 "blog_repository"   : "git@github.com:guyht/Guido.git",
 "author"            : "Glog",
 "blog_title"        : "The Glob Blog",
 "port"              : 8080,
 "base_url"          : "",
 "cache_time"        : 28800,
 "articles_per_page" : 10,
 "show_author"       : false,
 "plugins"           : [],
  "user" : {
    "custom-analytics-id" : "123",
    "custom-template-var" : "var"
 }
}

The user variable would be passed through to the template, giving the user access to all the variables defined in its scope.

Custom variables for articles would work in exactly the same way.

Opening for discussion

wlaurance commented 11 years ago

This also looks good to me. :+1: