Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for preprocessing the entire sass/less/css source with Li…
…quid.
- Loading branch information
Showing
8 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 2.1 | ||
- [x] Add support for processing text files with Liquid. | ||
- [ ] Process tag arguments with Liquid, not just values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module Jekyll | ||
module Assets | ||
module Addons | ||
module Processors | ||
class Liquid < Tilt::Template | ||
ProcessingFor = %W( | ||
text/css text/sass text/less text/scss | ||
text/coffeescript text/javascript | ||
) | ||
|
||
def prepare | ||
# | ||
end | ||
|
||
# Render the file with the sites current context, anything you | ||
# can do in a normal liquid file with Jekyll, you can do here inc, | ||
# accessing the entirety of your posts and pages, though I don't | ||
# know why you would want to, and I ain't judging you. | ||
|
||
def evaluate(scope, locals, jekyll = scope.environment.jekyll, &block) | ||
jekyll.liquid_renderer.file(@file).parse(data).render!( | ||
jekyll.site_payload, :registers => { | ||
:site => jekyll | ||
} | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
# There might be a few missing, if there is please do let me know. | ||
Jekyll::Assets::Addons::Processors::Liquid::ProcessingFor.each do |val| | ||
Sprockets.register_preprocessor val, Jekyll::Assets::Addons::Processors::Liquid | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.background { | ||
background: url(asset_path("{{ site.background_image }}")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
background_image: ruby.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Frozen-string-literal: true | ||
# Copyright: 2012-2015 - MIT License | ||
# Encoding: utf-8 | ||
|
||
require "rspec/helper" | ||
describe Jekyll::Assets::Addons::Processors::Liquid do | ||
let(:env) do | ||
Jekyll::Assets::Env.new(stub_jekyll_site) | ||
end | ||
|
||
it "lets the user use Liquid" do | ||
source = env.find_asset("liquid").to_s | ||
expect(source).not_to(match(/\{{2}\s*site\.background_image\s*\}{2}/)) | ||
expect(source).to(match(/background:\s*url\("\/assets\/ruby\.png"\)/)) | ||
end | ||
end |