Change template text dynamically

Hi all.
Is possible in same way, to change the text of a template node depending on a content of a file?

Example:
I read a file:
If, the content of that file is 1, then, a part of text in template, must be 111111
If, the content of that file is 2, then, a part of text in template, must be 222222
If, the content of that file is 3, then, a part of text in template, must be 333333

Thanks

Don't know what it is you want to achieve but this works:

[
    {
        "id": "cd95808ee2c88012",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "a4208e8a679d608c",
        "type": "ui_template",
        "z": "cd95808ee2c88012",
        "group": "2dee2e04.7cf00a",
        "name": "Log Anzeige",
        "order": 7,
        "width": "15",
        "height": "14",
        "format": "<p id='text_xcvy124'>{{text}}</p>\n\n\n<script>\n    (function(scope) {\n        scope.text = 'This text is completely useless';\n        scope.original = scope.text;\n\n        scope.setText = function(nr){\n            switch(nr){\n                case 1:\n                    scope.text = scope.original.replace(/text/i, \"111111\");\n                    break;\n                case 2:\n                    scope.text = scope.original.replace(/text/i, \"222222\");\n                    break;\n                case 3:\n                    scope.text = scope.original.replace(/text/i, \"333333\");\n                    break;\n                default:\n                    scope.text = scope.original;\n                    break;\n            }\n        }\n        \n        //handle arriving messages\n        scope.$watch('msg', function(msg) {\n\t\t\t    try{\n        \t\t    const nr = parseInt(msg.payload);\n        \t\t    scope.$applyAsync(scope.setText(nr));\n\t\t\t    }catch(err){\n\t\t\t        //console.error(err);\n\t\t\t    }\n        });\n    })(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": false,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "",
        "x": 990,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "2b14afc2e82b06c7",
        "type": "function",
        "z": "cd95808ee2c88012",
        "name": "Next",
        "func": "msg.topic = 'File'\nmsg.payload = msg.payload[0].replace(/\\n*$/, \"\").trim();\nreturn [msg, {tick:true}];",
        "outputs": 2,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 630,
        "y": 440,
        "wires": [
            [
                "a4208e8a679d608c",
                "6ac3d954df84eeca"
            ],
            [
                "9b6e7b40b6133601"
            ]
        ]
    },
    {
        "id": "9b6e7b40b6133601",
        "type": "chunks-to-lines",
        "z": "cd95808ee2c88012",
        "name": "",
        "nbLines": 1,
        "linesFormat": "json",
        "decoder": "UTF-8",
        "x": 640,
        "y": 560,
        "wires": [
            [
                "2b14afc2e82b06c7"
            ]
        ]
    },
    {
        "id": "cad297235e92bc5a",
        "type": "ui_upload",
        "z": "cd95808ee2c88012",
        "group": "2dee2e04.7cf00a",
        "title": "Drop Text File    (*.txt , utf-8)",
        "name": "upload",
        "order": 2,
        "width": 0,
        "height": 5,
        "chunk": 256,
        "transfer": "binary",
        "x": 270,
        "y": 560,
        "wires": [
            [
                "9b6e7b40b6133601"
            ]
        ]
    },
    {
        "id": "6ac3d954df84eeca",
        "type": "debug",
        "z": "cd95808ee2c88012",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1010,
        "y": 460,
        "wires": []
    },
    {
        "id": "2dee2e04.7cf00a",
        "type": "ui_group",
        "name": "Control",
        "tab": "721af69.d130208",
        "order": 1,
        "disp": true,
        "width": "15",
        "collapse": false,
        "className": ""
    },
    {
        "id": "721af69.d130208",
        "type": "ui_tab",
        "name": "Text",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

Thank you for the reply.
I was on holiday. Tomorrow I will try your solution
Bye

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.