-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch gears on experimental component functionality (#5)
* Switch gears on experimental component functionality Now based on Shopify's new Render tag * Fix for CI build * Temporarily disable default-site test in CI * Add support for multiple components paths * Update changelog and roadmap, releasing 0.10.0
- Loading branch information
1 parent
526ab49
commit 7467cc6
Showing
25 changed files
with
174 additions
and
80 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
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
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
36 changes: 36 additions & 0 deletions
36
bridgetown-core/lib/bridgetown-core/liquid_renderer/file_system.rb
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 @@ | ||
# frozen_string_literal: true | ||
|
||
module Bridgetown | ||
class LiquidRenderer | ||
class FileSystem < Liquid::LocalFileSystem | ||
def read_template_file(template_path) | ||
load_paths = root | ||
found_paths = [] | ||
|
||
load_paths.each do |load_path| | ||
# Use Liquid's gut checks to verify template pathname | ||
self.root = load_path | ||
full_template_path = full_path(template_path) | ||
|
||
# Look for .liquid as well as .html extensions | ||
path_variants = [ | ||
Pathname.new(full_template_path), | ||
Pathname.new(full_template_path).sub_ext(".html"), | ||
] | ||
|
||
found_paths << path_variants.find(&:exist?) | ||
end | ||
|
||
# Restore pristine state | ||
self.root = load_paths | ||
|
||
found_paths.compact! | ||
|
||
raise Liquid::FileSystemError, "No such template '#{template_path}'" if found_paths.empty? | ||
|
||
# Last path in the list wins | ||
::File.read(found_paths.last) | ||
end | ||
end | ||
end | ||
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
This file was deleted.
Oops, something went wrong.
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
32 changes: 32 additions & 0 deletions
32
bridgetown-core/lib/bridgetown-core/tags/render_content.rb
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,32 @@ | ||
# frozen_string_literal: true | ||
|
||
module Bridgetown | ||
module Tags | ||
class BlockRenderTag < Liquid::Block | ||
def initialize(tag_name, markup, options) | ||
super | ||
|
||
@tag = tag_name | ||
@markup = markup | ||
@options = options | ||
end | ||
|
||
def render(context) | ||
content = super.gsub(%r!^[ \t]+!, "") # unindent the incoming text | ||
|
||
site = context.registers[:site] | ||
converter = site.find_converter_instance(Bridgetown::Converters::Markdown) | ||
markdownified_content = converter.convert(content) | ||
|
||
context.stack do | ||
context["componentcontent"] = markdownified_content | ||
render_params = "#{@markup}, content: componentcontent" | ||
render_tag = Liquid::Render.parse("render", render_params, @options, @parse_context) | ||
render_tag.render_tag(context, +"") | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
Liquid::Template.register_tag("rendercontent", Bridgetown::Tags::BlockRenderTag) |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Bridgetown | ||
VERSION = "0.9.0" | ||
VERSION = "0.10.0" | ||
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
10 changes: 2 additions & 8 deletions
10
bridgetown-core/test/source/src/_components/test_component.html
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 |
---|---|---|
@@ -1,9 +1,3 @@ | ||
<span id='include-param'>{{include.param}}</span> | ||
<span id='include-param'>{{param}}</span> | ||
|
||
<ul id='param-list'> | ||
{% for param in include %} | ||
<li>{{param[0]}} = {{param[1]}}</li> | ||
{% endfor %} | ||
</ul> | ||
|
||
{{ include.content}} | ||
<main>{{ content}}</main> |
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
source "https://rubygems.org" | ||
|
||
# Pull in latest Liquid from Shopify with new Render tag | ||
gem 'liquid', "> 4.0.3", github: "jaredcwhite/liquid" | ||
|
||
gem 'bridgetown-core', path: '../bridgetown-core' | ||
gem 'bridgetown-paginate', path: '../bridgetown-paginate' |
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,11 @@ | ||
{%- if extra_margin -%} | ||
{%- assign extra_margin_class = "my-10" -%} | ||
{%- endif -%} | ||
|
||
<div class="note {{ type }} {{ extra_margin_class }}"> | ||
{%- if title -%} | ||
<h5>{{ title }}</h5> | ||
{%- endif -%} | ||
|
||
{{- content -}} | ||
</div> |
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
File renamed without changes.
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
Oops, something went wrong.