Skip to content

Commit

Permalink
updates to mogrt
Browse files Browse the repository at this point in the history
  • Loading branch information
inlife committed Aug 15, 2024
1 parent 17d52ca commit 032a10b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
24 changes: 21 additions & 3 deletions packages/nexrender-action-mogrt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ This plugin adds .mogrt support to Nexrender.

1. Set a .mogrt file as the `template.src` value
2. Add this module in predownload actions
3. Add any Essential Graphics parameters you want to change as `essentialParameters`
3. Add any Essential Graphics parameters you want to change as `params`
4. Use unique layer names in the .mogrt file to reference assets to leverage nexrender built-in asset substitution


```json
Expand All @@ -19,13 +20,31 @@ This plugin adds .mogrt support to Nexrender.
"src": "http://www.foo.com/template.mogrt",
"composition": "will_be_ignored"
},
"assets": [
{
"type": "image",
"src": "http://www.foo.com/image.png",
"layerName": "$ref-layer-1"
},
{
"type": "image",
"src": "http://www.foo.com/image2.png",
"layerName": "$ref-layer-2"
}
],
"actions": {
"predownload": [
{
"module": "nexrender-action-mogrt-template",
"essentialParameters": {
"params": {
"Title": "This should be the title",
"Dropdown": 2,
"Group Name": {
"Some Name": "Some Value",
"Another Name": 123
},
"My First Image": "$ref-image-1",
"My Second Image": "$ref-image-2"
"Scale": [50, 50],
"Checkbox": true,
"Point Control:": [30, 50],
Expand All @@ -43,5 +62,4 @@ This plugin adds .mogrt support to Nexrender.

* Any `template.src` without a .mogrt extension will be ignored
* The value in `template.composition` will be ignored, as .mogrt files specify what composition to use on their own, but Nexrender requires one to be specified
* Media replacement through essential graphics isn't supported (yet), but normal asset injection with Nexrender will work
* Invalid .mogrt files will cause an error
4 changes: 2 additions & 2 deletions packages/nexrender-action-mogrt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ module.exports = async (job, settings, options, type) => {
settings.logger = settings.logger ?? console;
const jsxUrl = url.pathToFileURL(path.join(__dirname, 'applyEssentialValues.jsx')).toString();
if (type === 'predownload') {
if (typeof options.essentialParameters !== 'undefined') {
if (typeof options.params !== 'undefined') {
job.assets.unshift({
src: jsxUrl,
keyword: '_essential',
type: 'script',
parameters: [
{
key: 'essentialParameters',
value: Object.assign({}, options.essentialParameters)
value: Object.assign({}, options.params)
}
]
})
Expand Down
2 changes: 1 addition & 1 deletion packages/nexrender-action-mogrt/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("action/mogrt",() => {
},
settings: {},
options: {
essentialParameters: {
params: {
foo: 'bar',
}
},
Expand Down

0 comments on commit 032a10b

Please sign in to comment.