Announcement

Collapse
No announcement yet.

[CLOSED] [#1271] Inject header comment into generated js file

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    [CLOSED] [#1271] Inject header comment into generated js file

    I'd like to include a license comment at the top of the generated js file for my module. How can this be accomplished?
    Last edited by Daniil; 2016-05-02 @ 04:17 PM.

    #2
    Would post build command do the trick?

    Comment


      #3
      The [Init] Attribute should work for this.

      http://bridge.net/kb/attribute-reference/#Init

      Mark a Method with [Init(InitPosition.Top)] and anything within the Method will be rendered to the top of the file.

      Hope this helps.

      Comment


        #4
        The following sample demonstrates.

        Example (Live)

        public class App
        {
            [Ready]
            public static void Main()
            {
                Global.Alert("Hello, World");
            }
            
            [Init(InitPosition.Top)]
            public static void Top()
            {
                /*
                    This is a multi-line comment
                */
            }
        }
        Example (JS output)

        /*
            This is a multi-line comment
        */
        
        (function (globals) {
            "use strict";
        
            Bridge.define('Demo.App', {
                statics: {
                    config: {
                        init: function () {
                            Bridge.ready(this.main);
                        }
                    },
                    main: function () {
                        Bridge.global.alert("Hello, World");
                    }
                }
            });
            
            Bridge.init();
        })(this);
        Hope this helps.

        Comment


          #5
          Thanks, that should work. Would it be possible to have a compilation option to specify a header text file in future versions?

          Comment


            #6
            Hi johnwason,

            I've created a feature request for your suggestion of using text file as the header template, see Issue #1271:

            https://github.com/bridgedotnet/Bridge/issues/1271

            Comment


              #7
              There is a new resources bridge.json config option in 15.0:
              To use a file header just specify either remark or header:

              "resources": [{
                          // A default section (a section with no name setting)
                          // Should be one per all resources
                          // Values defined here will be applied to all resources (if not overridden)
              
                          // A string with a header content 
                          // or a path to a file with header content
                          // Supports tokens (data taken from assembly vresion): 
                          //     {version}
                          //     {date}
                          //     {year}
                          //     {author}
                          //     {copyright}
                          "header":  "../header.txt"
              
                          // Specifies if a line will be inserted before each file
                          // Supports tokens:
                          //     {name}
                          //     {path}
                          //     \n
                          // Default is null
                          "remark": "// source @{name}\n"
                      }
              ]
              See #1271 for details.

              Comment

              Working...
              X