Skip to content

Passing variables to the templates #28

Description

@guyht

/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:

  • Pass custom variables from the config file to the template (e.g. tracking ids)
  • Pass custom variables from an article to the template (e.g. article image, references)

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

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions