@soleil-se/app-util 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/index.js +4 -4
- package/package.json +1 -1
- package/src/index.js +2 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
```javascript
|
|
7
7
|
import { renderApp, getRouteUri, getResourceUri, renderTemplate, isOffline } from '@soleil-se/webapp-util';
|
|
8
8
|
```
|
|
9
|
-
### `renderApp(name, data, [
|
|
9
|
+
### `renderApp(name, [data], [settings])` ⇒ `String`
|
|
10
10
|
Get HTML string for rendering an application.
|
|
11
11
|
To be used together with `@soleil-se/webapp-util/render-vue` or a custom render function in the client code.
|
|
12
12
|
|
|
@@ -15,8 +15,8 @@ To be used together with `@soleil-se/webapp-util/render-vue` or a custom render
|
|
|
15
15
|
| Param | Type | Default | Description |
|
|
16
16
|
| --- | --- | --- | --- |
|
|
17
17
|
| name | <code>String</code> | | Name of the app, has to match the name of the application. |
|
|
18
|
-
| data | <code>Object</code> |
|
|
19
|
-
| settings | <code>Object</code> |
|
|
18
|
+
| [data] | <code>Object</code> | <code>{}</code> | Server data that will be available in the app. In Vue it will be available in the `$options` object. |
|
|
19
|
+
| [settings] | <code>Object</code> | <code>{}</code> | Settings object. |
|
|
20
20
|
| [settings.noScript] | <code>String</code> | <code>''</code> | HTML that will be rendered when JavaScript is not available. |
|
|
21
21
|
| [settings.selector] | <code>String</code> | <code>`[data-portlet-id="${portletId}"]`</code> | Query selector for where the app should be mounted. |
|
|
22
22
|
| [settings.async] | <code>Boolean</code> | <code>true</code> | If the app script should be loaded asynchronously. [Read more about async and defer.](https://flaviocopes.com/javascript-async-defer/) |
|
|
@@ -38,7 +38,7 @@ router.get('/', (req, res) => {
|
|
|
38
38
|
}));
|
|
39
39
|
});
|
|
40
40
|
```
|
|
41
|
-
Vue
|
|
41
|
+
##### **Vue**
|
|
42
42
|
In `app_src/vue/index.js`.
|
|
43
43
|
```javascript
|
|
44
44
|
import render from '@soleil-se/webapp-util/render-vue';
|
package/dist/index.js
CHANGED
|
@@ -38,9 +38,9 @@ export function renderTemplate(template, values) {
|
|
|
38
38
|
/**
|
|
39
39
|
* Get HTML string for rendering an application.
|
|
40
40
|
* @param {String} name Name of the app, has to match the name of the application.
|
|
41
|
-
* @param {Object} data Server data that will be available in the app.
|
|
41
|
+
* @param {Object} [data={}] Server data that will be available in the app.
|
|
42
42
|
* In Vue it will be available in the `$options` object.
|
|
43
|
-
* @param {Object} settings Settings object.
|
|
43
|
+
* @param {Object} [settings={}] Settings object.
|
|
44
44
|
* @param {String} [settings.noScript=''] HTML that will be rendered when JavaScript
|
|
45
45
|
* is not available.
|
|
46
46
|
* @param {String} [settings.selector=`[data-portlet-id="${portletId}"]`] Query selector for
|
|
@@ -62,9 +62,9 @@ export function renderApp(name, data, ref) {
|
|
|
62
62
|
var clientUri = getResourceUri('client/index.js');
|
|
63
63
|
|
|
64
64
|
if (isOffline) {
|
|
65
|
-
return ("\n<!-- Generated by WebappUtil.
|
|
65
|
+
return ("\n<!-- Generated by WebappUtil." + (this.name) + "() -->\n<div data-portlet-id=\"" + portletId + "\">" + noScript + "</div>\n<script src=\"" + clientUri + "\"></script>\n<script> \n Soleil.webapps['" + name + "'].render('" + name + "', '" + selector + "', " + (JSON.stringify(options)) + ");\n</script>\n");
|
|
66
66
|
}
|
|
67
|
-
return ("\n<!-- Generated by WebappUtil.
|
|
67
|
+
return ("\n<!-- Generated by WebappUtil." + (this.name) + "() -->\n<div data-portlet-id=\"" + portletId + "\">" + noScript + "</div>\n<script>\n function renderApp" + portletId + "() {\n Soleil.webapps['" + name + "'].render('" + name + "', '" + selector + "', " + (JSON.stringify(options)) + ");\n } \n</script>\n<script src=\"" + clientUri + "\" " + (async && !defer ? 'async' : '') + " " + (defer ? 'defer' : '') + " onload=\"renderApp" + portletId + "();\"></script>\n");
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -36,9 +36,9 @@ export function renderTemplate(template, values = {}) {
|
|
|
36
36
|
/**
|
|
37
37
|
* Get HTML string for rendering an application.
|
|
38
38
|
* @param {String} name Name of the app, has to match the name of the application.
|
|
39
|
-
* @param {Object} data Server data that will be available in the app.
|
|
39
|
+
* @param {Object} [data={}] Server data that will be available in the app.
|
|
40
40
|
* In Vue it will be available in the `$options` object.
|
|
41
|
-
* @param {Object} settings Settings object.
|
|
41
|
+
* @param {Object} [settings={}] Settings object.
|
|
42
42
|
* @param {String} [settings.noScript=''] HTML that will be rendered when JavaScript
|
|
43
43
|
* is not available.
|
|
44
44
|
* @param {String} [settings.selector=`[data-portlet-id="${portletId}"]`] Query selector for
|