postcss-liquid-variables
Advanced tools
Comparing version 1.0.0 to 1.0.1
30
index.js
var postcss = require('postcss'); | ||
var bgUrlRegex = /url\([\s'"]?(.*?)[\s'"]?\)/g; | ||
var protocolRegex = /(https?:)?\/\/|data:/g; | ||
module.exports = postcss.plugin('postcss-liquid-variables', | ||
@@ -19,26 +16,7 @@ function (opts) { | ||
node.value = node.value | ||
.replace(/^([^\$]*)(\$\()([^\)]+)(\))(.*)$/, | ||
function(match, $1, $2, $3, $4, $5) { | ||
return $1 + '{{ ' + $3 + ' }}' + $5; | ||
}); | ||
.replace(/^([^\$]*)(\$\()([^\)]+)(\))(.*)$/, | ||
function(match, $1, $2, $3, $4, $5) { | ||
return $1 + '{{ ' + $3 + ' }}' + $5; | ||
}); | ||
} | ||
if ( bgUrlRegex.test(node.value) && | ||
!protocolRegex.test(node.value) ) { | ||
node.value = node.value.replace(bgUrlRegex, | ||
function(match, $1) { | ||
var urlAndFilters = $1.split('|'); | ||
var newVal = 'url({{ "'; | ||
urlAndFilters.forEach(function (current, index) { | ||
if (index === 0) { | ||
newVal += current.replace(/'|"/g, '') | ||
.trim(); | ||
newVal += '" | asset_url '; | ||
} else { | ||
newVal += '| ' + current.trim() + ' '; | ||
} | ||
}); | ||
newVal += '}})'; | ||
return newVal; | ||
}); | ||
} | ||
} | ||
@@ -45,0 +23,0 @@ }); |
{ | ||
"name": "postcss-liquid-variables", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "PostCSS plugin for using Liquid variables in CSS files.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
# PostCSS Liquid Variables | ||
[PostCSS] plugin to allow use of Liquid theme variables in CSS files. | ||
PostCSS plugin to allow use of Liquid theme variables in CSS files. | ||
@@ -17,3 +17,3 @@ Forked from [PostCSS Shopify Settings Variables](https://github.com/bit3725/postcss-shopify-settings-variables) and adjusted slightly for use with non-Shopify Liquid templates. | ||
.foo { | ||
background-color: {{ theme_preferences.background_colour }}; /* Shopify friendly values */ | ||
background-color: {{ theme_preferences.background_colour }}; | ||
} | ||
@@ -28,2 +28,2 @@ ``` | ||
See [PostCSS] docs for examples for your environment. | ||
See PostCSS docs for examples for your environment. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3620
20