Skip to content

Global custom fields in a specs #193

@synopticum

Description

@synopticum

SourceJS doesn't provide an opportunity to change the URL to the master-app styles dynamicaly.
Currently, this URL should be hardcoded in the template(s) like this:
<link href="http://production-server.com/css/all.css" rel="stylesheet" data-source="core">

I would like to be able to change http://production-server in the all specs dymanicaly, for example, after the POST request to SourceJS server. I think, it might be a global variable in the options.js. Expected result:
<link href="<%= urlToApplication %>/css/all.css" rel="stylesheet" data-source="core">

Also, I would like to use urlToApplication not only in the spec templates. I use requirejs calls in the /spec/js/initSpec.js to include an external components to my spec:

requirejs.config({
    baseUrl: 'http://production-server.com/js/libraries',
    paths: {
        'jquery': 'jquery-2.1.0/jquery.min',
        'underscore': 'underscore/underscore-min',
        'backbone': 'backbone/backbone-min',
        'backgrid': 'backgrid'
    },
    shim: {
        'backgrid': {
            deps: ['jquery', 'underscore', 'backbone'],
            exports: 'Backgrid'
        }
    }
});

require(['jquery', 'underscore', 'backbone', 'backgrid' ], initPage);

Although, of course, I could add this initialization to the spec file:

<script>
requirejs.config({
    baseUrl: '<%= urlToApplication %>/js/libraries',
    paths: {
    ....
</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions