Skip to content

Include JSON content #194

Answered by fralau
Andre601 asked this question in Q&A
Nov 28, 2023 · 3 comments · 3 replies
Discussion options

You must be logged in to vote

If my understanding is correct, it should be straightfoward:

  1. Define a macro read_json_file() in main.py which is a function that returns the json variable.
  2. Slam the template directly in the markdown page where it is fits.

I haven't tested but it should be along those lines:

def define_env(env):
    """
    This is the hook for defining variables, macros and filters

    - variables: the dictionary that contains the environment variables
    - macro: a decorator function, to declare a macro.
    - filter: a function with one of more arguments,
        used to perform a transformation
    """

   @env.macro
   def read_json_file(): 
       "Return json variable"
        path = "assets/ext…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@Andre601
Comment options

@Andre601
Comment options

Answer selected by Andre601
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Andre601
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants