I tried the new npm package @wordpress/create-block
to generate custom blocks in WordPress.
The file view.js
was created automatically in my blocks folder. In the view.js
i can write JavaScript Code for my custom block.
Now i want to use the block attributes in view.js
but i cannot find in wp docs how to pass the information into my view.js file?
I placed the attributes in block.json
.
"attributes": {
"content": {
"type": "string",
"source": "html",
"selector": "h2",
},
"question": {
"type": "string",
"source": "html",
"selector": "div",
},
"autoplay": {
"type": "boolean",
},
"loop": {
"type": "boolean",
},
},
How can i use for e.g. the attributes.autoplay
or attributes.loop
in view.js?