fix: use single quotes for x-data attributes with tojson
The Jinja |tojson filter outputs JSON with double quotes. When used
inside a double-quoted HTML attribute, these quotes break the attribute
parsing causing "expected expression, got '}'" errors.
Solution: Use single quotes for x-data attributes so JSON double quotes
don't conflict:
<div x-data='languageSelector("fr", {{ langs|tojson }})'>
Updated:
- language_selector.html macro (all 3 variants)
- shop/base.html language selector
- LANG-002 and LANG-003 architecture rules documentation
- Validator to detect double-quoted x-data with tojson
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -57,8 +57,9 @@
|
||||
{% set current = current_language if current_language in langs else langs[0] %}
|
||||
{% set positions = {'left': 'left-0', 'right': 'right-0'} %}
|
||||
{# Uses languageSelector() function per LANG-002 architecture rule #}
|
||||
{# Use single quotes for x-data so JSON double quotes don't break the attribute #}
|
||||
<div
|
||||
x-data="languageSelector('{{ current }}', {{ langs | tojson }})"
|
||||
x-data='languageSelector("{{ current }}", {{ langs | tojson }})'
|
||||
class="relative inline-block"
|
||||
>
|
||||
<button
|
||||
@@ -120,8 +121,9 @@
|
||||
{% set current = current_language if current_language in langs else langs[0] %}
|
||||
{% set positions = {'left': 'left-0', 'right': 'right-0'} %}
|
||||
{# Uses languageSelector() function per LANG-002 architecture rule #}
|
||||
{# Use single quotes for x-data so JSON double quotes don't break the attribute #}
|
||||
<div
|
||||
x-data="languageSelector('{{ current }}', {{ langs | tojson }})"
|
||||
x-data='languageSelector("{{ current }}", {{ langs | tojson }})'
|
||||
class="relative"
|
||||
>
|
||||
<button
|
||||
@@ -178,8 +180,9 @@
|
||||
{% set langs = enabled_languages[:2] if enabled_languages else ['fr', 'de'] %}
|
||||
{% set current = current_language if current_language in langs else langs[0] %}
|
||||
{# Uses languageSelector() function per LANG-002 architecture rule #}
|
||||
{# Use single quotes for x-data so JSON double quotes don't break the attribute #}
|
||||
<div
|
||||
x-data="languageSelector('{{ current }}', {{ langs | tojson }})"
|
||||
x-data='languageSelector("{{ current }}", {{ langs | tojson }})'
|
||||
class="inline-flex items-center gap-1 p-1 bg-gray-100 dark:bg-gray-700 rounded-lg"
|
||||
>
|
||||
<template x-for="lang in languages" :key="lang">
|
||||
|
||||
Reference in New Issue
Block a user