You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+9-10
Original file line number
Diff line number
Diff line change
@@ -92,14 +92,13 @@ You then need to call `scratchblocks.renderMatching` after the page has loaded.
92
92
Make sure this appears at the end of the page (just before the closing `</body>` tag):
93
93
```js
94
94
<script>
95
-
scratchblocks.renderMatching('pre.blocks', {
95
+
snapblocks.renderMatching('pre.blocks', {
96
96
style:'snap', // Optional, defaults to 'scratch2'.
97
97
languages: ['en', 'de'], // Optional, defaults to ['en'].
98
98
scale:1, // Optional, defaults to 1
99
99
});
100
100
</script>
101
101
```
102
-
Note: this does use `scratchblocks` so it's easier to migrate from scratchblocks to snapblocks.
103
102
104
103
The `renderMatching()` function takes a CSS-style selector for the elements that contain snapblocks code: we use `pre.blocks` to target `pre` tags with the class `blocks`.
105
104
@@ -115,9 +114,9 @@ I'm rather fond of the <code class="b">cut from [ v]</code> block in Snap.
115
114
To allow this, make a second call to `renderMatching` using the `inline` argument.
116
115
```js
117
116
<script>
118
-
scratchblocks.renderMatching("pre.blocks", ...)
117
+
snapblocks.renderMatching("pre.blocks", ...)
119
118
120
-
scratchblocks.renderMatching("code.b", {
119
+
snapblocks.renderMatching("code.b", {
121
120
inline:true,
122
121
// Repeat `style` and `languages` options here.
123
122
});
@@ -139,15 +138,15 @@ The translations files are hundreds of kilobytes in size, so to keep your page b
139
138
140
139
For example, a translations file that just loads the German language (ISO code `de`) would look something like this:
141
140
```js
142
-
window.scratchblocks.loadLanguages({
141
+
window.snapblocks.loadLanguages({
143
142
de:<contents of locales/de.json>
144
143
})
145
144
```
146
145
147
146
If you're using a JavaScript bundler you should be able to build your own translations file by calling `require()` with the path to the locale JSON file.
148
147
This requires your bundler to allow importing JSON files as JavaScript.
Since version 3.6.0, scratchblocks (and subsequently snapblocks) can be properly loaded as an ESM module. The ESM version, instead of defining `window.scratchblocks`, default-exports the `scratchblocks` object. Similarly, the JavaScript translation files default-exports a function to load the translations.
168
+
Since version 3.6.0, scratchblocks (and subsequently snapblocks) can be properly loaded as an ESM module. The ESM version, instead of defining `window.snapblocks`, default-exports the `snapblocks` object. Similarly, the JavaScript translation files default-exports a function to load the translations.
0 commit comments