Jade conditions inside script tag

I am adding Javascript to the jade template, and the problem I am having is duplicating the code because I cannot execute any jade legend inside the script tag. In any case, the code is below.

if streamingType == 'HLS_IOS'
    script
        :coffee(bare=true)
         window.$j = jQuery
         window.player = new HtmlPlayer $j('#wrapper')
         player._loadVideoAt '#{url}'
else
    script
        :coffee(bare=true)
        window.$j = jQuery
        window.player = new FlashPlayer $j('#wrapper'), '#{flashPlayerId}'
        player._loadVideoAt '#{url}'`
+4
source share
1 answer

You can use the conventions inside the script tag in the latest jade versions:

script
    | window.$j = jQuery;
    if streamingType == 'HLS_IOS'
        | window.player = new HtmlPlayer($j('#wrapper'));
    else
        | window.player = new FlashPlayer($j('#wrapper'), '#{flashPlayerId}');
    | player._loadVideoAt('#{url}');

Unfortunately, I did not find a way to use conventions and filters at the same time, so you may need to write simple javascript.

+5
source

Source: https://habr.com/ru/post/1527610/


All Articles