cancel
Showing results for 
Search instead for 
Did you mean: 

Add Comments to Blox

gwolfe
10 - ETL
10 - ETL

This may be a stupid question, but how to I add comments to the Blox editor? 

// and /* */ both seem to work as I edit the script. However, after hitting "Apply" and returning to the editor my comments disappear. 

Some of our scripts get really long and comments would be helpful. 

Thanks, 

1 ACCEPTED SOLUTION

JeremyFriedel
Sisense Team Member
Sisense Team Member

Hi @gwolfe,

In testing in the Blox editor, using opening and terminating comment syntax (/* */) worked without issue:

 

 

{
    "style": "",
    "script": "/* Test Comment */ console.log('Test'); /* Test Comment2 */ console.log('Second Test'); /* Test Comment3 */ console.log('Third Test');",
    "title": "",
    "showCarousel": true,
    "body": [
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "❤️️ Welcome to BloX ❤️️",
                    "style": {
                        "text-align": "center",
                        "font-weight": "bold",
                        "font-size": "24px",
                        "margin": "100px"
                    }
                }
            ]
        }
    ],
    "actions": []
}

 

 

Unfortunately, what was not saved by Blox was starting a new line in the script parameter in the Blox template, which was not accepted as valid by Blox, and all changes after using a new line character were lost.

 

For a more readable script editor UI, using the native Script Editor UI and widget events, are preferred, in the script editor there is no limitation on formatting of the script or how many lines the script uses. 

 

Alternatively, the code can be edited in a text editor/IDE with new lines present for readability, and when finished pasted in a single line when finished. Using the opening and terminating comment syntax (/* */) will work for comments.

 

Screen Shot 2024-05-17 at 12.01.13 PM.png.

View solution in original post

4 REPLIES 4

DRay
Community Team Leader
Community Team Leader

Hi @gwolfe,

Thank you for your question.

Are you referring to the template editor specific to Blox and not the script editor, which is the same for all widgets?

The template on reload will show the last valid Blox template that didn’t return an invalid template error when saving. If the Blox template has an error all unsaved changes are lost, so it is a good idea to click accept often to limit the potential for this type of loss of progress.

David Raynor (DRay)

gwolfe
10 - ETL
10 - ETL

Thanks @DRay  I am talking about the editor specific to Blox. I understand that it shows the last valid template. The question is how do I add comments? They look to be valid, but disappear after saving. 

JeremyFriedel
Sisense Team Member
Sisense Team Member

Hi @gwolfe,

In testing in the Blox editor, using opening and terminating comment syntax (/* */) worked without issue:

 

 

{
    "style": "",
    "script": "/* Test Comment */ console.log('Test'); /* Test Comment2 */ console.log('Second Test'); /* Test Comment3 */ console.log('Third Test');",
    "title": "",
    "showCarousel": true,
    "body": [
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "❤️️ Welcome to BloX ❤️️",
                    "style": {
                        "text-align": "center",
                        "font-weight": "bold",
                        "font-size": "24px",
                        "margin": "100px"
                    }
                }
            ]
        }
    ],
    "actions": []
}

 

 

Unfortunately, what was not saved by Blox was starting a new line in the script parameter in the Blox template, which was not accepted as valid by Blox, and all changes after using a new line character were lost.

 

For a more readable script editor UI, using the native Script Editor UI and widget events, are preferred, in the script editor there is no limitation on formatting of the script or how many lines the script uses. 

 

Alternatively, the code can be edited in a text editor/IDE with new lines present for readability, and when finished pasted in a single line when finished. Using the opening and terminating comment syntax (/* */) will work for comments.

 

Screen Shot 2024-05-17 at 12.01.13 PM.png.

Thanks @JeremyFriedel , although it's not the answer I was looking for, you did answer my question. We are looking to add comments as new lines. Some of our blox widgets can have hundreds of lines of code. We will go with the text editor approach.