The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Pretty Print Raw MiniJinja JSON Data On A Template

TODO: Pull subtitle into page object
Code
<input type="hidden" id="neo_string" value="{% autoescape true %}{{ page.all_sections() }}{% endautoescape %}" />
    <pre id="neo_formatted"></pre>
    <script>
      const updateIt = () => {
        neo_formatted.innerText = JSON.stringify(
          JSON.parse(neo_string.value.replaceAll('None', `"None"`)),
          null,
          2
        )
      }
      document.addEventListener('DOMContentLoaded', updateIt)
    </script>

Notes

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Pretty Print Raw MiniJinja JSON Data On A Template

I use MiniJinja^mj^^ to create the templates for my site. 
The output data comes in from Serde^se^^ in a JSON like
syntax. I use this snippet to pretty print it
so it's easier to work with:


-- code
-- javascript

    <input type="hidden" id="neo_string" value="{% autoescape true %}{{ page.all_sections() }}{% endautoescape %}" />
    <pre id="neo_formatted"></pre>
    <script>
      const updateIt = () => {
        neo_formatted.innerText = JSON.stringify(
          JSON.parse(neo_string.value.replaceAll('None', `"None"`)),
          null,
          2
        )
      }
      document.addEventListener('DOMContentLoaded', updateIt)
    </script>


-- notes

- This goes in a template that receives data in a `page`` 
context variable

- The data is placed in a hidden input element to start with
then scrubbed and output in the `pre`` tag when the page 
is loaded

- I have optional values that come across in the origial data
as `None`` without quotes. The script adds the qutoes to 
diminish parsing issues


-- ref
-- url: https://serde.rs/

-- ref
-- url: https://docs.rs/minijinja/latest/minijinja/

-- ref
-- url: https://www.alanwsmith.com/neopolitan/

-- ref
-- url: https://www.alanwsmith.com/neopoligin/


-- categories
-- Rust 
-- Neopolitan 
-- Neopoligin

-- metadata
-- date: 2023-07-21 15:03:07
-- id: 2stw7at2
-- site: aws
-- type: post
-- status: published