Search code examples
phpphalconvolt

Tag helpers on external URLs without protocol


I am attempting to use volt tag helpers such as stylesheet_link to link to an external URL without protocol prefix.

Example usage without protocol proves to be problem free:

{{ stylesheet_link('http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css') }}

Generates

<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />

.

However, whenever the protocol prefix is obmitted (ie/ //netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css):

{{ stylesheet_link('//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css') }}

Generates incorrect URL:

<link rel="stylesheet" type="text/css" href="[SITE_PREFIX]//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />

Is it due to my incorrect usage? or is this an existing bug with volt?


Solution

  • Try specifying that it's not local, see the docs.

    {{ stylesheet_link('//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css', false) }}