Skip to content

Conversation

@thekid
Copy link
Member

@thekid thekid commented Sep 27, 2025

This helper can be used to transport values from PHP to JavaScript:

<script>
  let person = {{&json person}};
  console.log(person.name);
</script>

See also https://stackoverflow.com/questions/10232574/need-handlebars-js-to-render-object-data-instead-of-object-object and https://laravel.com/docs/master/blade#rendering-json

@thekid thekid added the enhancement New feature or request label Sep 27, 2025
"xp-forge/frontend": "^7.0 | ^6.0",
"xp-forge/handlebars": "^10.0 | ^9.3",
"xp-forge/yaml": "^9.0 | ^8.0 | ^7.0 | ^6.0",
"xp-forge/json": "^6.0 | ^5.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not add a new dependency, xp-forge/json was already required by xp-forge/frontend.

@thekid thekid merged commit 378f50e into main Sep 27, 2025
14 checks passed
@thekid thekid deleted the feature/json branch September 27, 2025 10:42
@thekid
Copy link
Member Author

thekid commented Sep 27, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants