Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-liquid-variables

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-liquid-variables - npm Package Compare versions

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 @@ });

2

package.json
{
"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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc