adamhajari / spyre

a web application framework for python
MIT License
832 stars 157 forks source link

Custom header and Custom JS should come at the end of <head> element #83

Closed gramster closed 6 years ago

gramster commented 6 years ago

I'm not sure what the motivation is for putting them where they are in view.html. Maybe there is one. However, if you want to use require.js, it will break if included in the current locations.

On the other hand, it will work if those are moved to end of head element, as in:

        </script>
        {{custom_head}}
        <script type='text/javascript'>
                {{custom_js}}
            </script>
    </head>

which can then be used with:

   def getCustomHead(self):
        return """
           <script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.16/require.js"></script>
           """

    def getCustomJS(self):
        return """
            require.config({
                paths: {
                    ...
                }
            });
            """

etc.

This still leaves the issue of serving up the scripts referenced from require; the simple solution is to add the ability to include an optional CherryPy config when starting the app; I discussed that here: https://github.com/adamhajari/spyre/issues/59

gramster commented 6 years ago

Created a pull request: https://github.com/adamhajari/spyre/pull/88

adamhajari commented 6 years ago

thanks for the PR @gramster