json 'dumps' filter for creating javascript with mako
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- javascript, python
Research direction
The issue names no files or tests. Start by locating Mako's existing filtering and escaping entry points and related template-output tests; use the examples to define the expected JSON-to-JavaScript escaping behavior, then add coverage showing that both single and double quotes remain valid.
Written by the indexing model from the issue text.
Description
Migrated issue, originally created by jvanasco (@jvanasco)
I ran into some issues with Mako when trying to make javascript using the output of json.dumps
# in python
python_dict = { "hello" : """This is an example object I am using some 'single quotes' and "double quotes".""", }
usually i can just disable filtering in mako :
// in js template
var payload = '${simplejson.dumps(python_dict)|n}';
unfortunately in this case the single-quotes break. we get this
// in js generated
var payload = '{"hello": "This is an example object I am using some 'single quotes' and \"double quotes\"."}'
this appears to work fine :
// in js template
var payload = '${simplejson.dumps(python_dict).encode('string-escape')|n}';
which generates
// in js generated
var payload = {"hello": "This is an example object I am using some \'single quotes\' and \\"double quotes\\"."}
there are a handful of miscellaneous JS+Mako questions floating on StackOverflow and blogs... so i think it might be worthwhile to have an official json escaping method in mako templates.
- Dominant language
- Python
- Stars
- 459
- Forks
- 96
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sqlalchemy/mako
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
sqlalchemy/mako#432 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
sqlalchemy/mako#417 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
sqlalchemy/mako#392 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
sqlalchemy/mako#382 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
sqlalchemy/mako#376 · 9 comments ·
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#133181 ·
Maintainers usually reply within 1 day
-
[oblt-aw][security] SEC-022 — findings (2026-10-05)Possibly taken @elastic-vault-github-plugin-prod claimed this today. Openoblt-aw/ai/fix-ready oblt-aw/detector/security oblt-aw/triage/security-secrets
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
elastic/oblt-aw#2304 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 Under an hour Newbie friendliness 90/100
huggingface/huggingface_hub#5083 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
deepset-ai/haystack#13107 ·
Maintainers usually reply within 1 day
-
[Bug]: index worker dies on LOG_LEVEL=info / empty / numeric before it can report a missing bootstrapPossibly taken @sxh313 claimed this today. Opentriage/confirmed
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
agentscope-ai/agentscope#3130 ·
Maintainers usually reply within 1 day