Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions _docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ GEM
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.4.3)
mercenary (0.4.0)
mini_portile2 (2.6.1)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
nokogiri (1.12.5-x86_64-linux)
racc (~> 1.4)
pathutil (0.16.2)
Expand Down Expand Up @@ -128,6 +132,7 @@ GEM
word_wrap (1.0.0)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
Expand Down
2 changes: 2 additions & 0 deletions _docs/_builds/snippets/includes_dirs_list.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

{"liquidoc"=>[{"dirs"=>"'_templates','_templates/liquid','_templates/liquid/ops','_templates/ops','theme/_includes','theme/_layouts'"}]}
12 changes: 12 additions & 0 deletions _docs/_ops/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
builds:
- output: _build/data/built/version.yml
template: _templates/version.yaml
- action: parse
data:
file: ../lib/liquidoc.rb
type: regex
pattern: '^\@includes_dirs_def\s\=\s\[(?<dirs>.*)\]'
builds:
- output: _build/data/built/includes_dirs.json
- action: parse
data: _build/data/built/includes_dirs.json
builds:
- output: _build/snippets/built/includes-dirs-list.adoc
template: _templates/includes-dirs-list.asciidoc
- action: render
source: index.adoc
data:
Expand Down
4 changes: 4 additions & 0 deletions _docs/_templates/includes-dirs-list.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{%- assign list = data.liquidoc[0]['dirs'] | replace:"'","" | split:"," %}
{%- for item in list %}
* `{{ item }}`
{%- endfor %}
6 changes: 6 additions & 0 deletions _docs/topics/reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ s| variables
| N/A
| N/A

s| includes_dirs
| Optional
| N/A
| N/A
| N/A

s| properties
| N/A
| N/A
Expand Down
29 changes: 29 additions & 0 deletions _docs/topics/templating_liquid.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,35 @@ LiquiDoc does not have an equivalent of https://jekyllrb.com/docs/liquid/tags/#c
For now, we will leave Liquid's core tags best documented in Shopify's https://shopify.github.io/liquid/[official Liquid documentation], as augmented by their https://github.com/shopify/liquid/wiki/Liquid-for-Designers[Liquid for Designers].
Ignore all of Jekyll's tag documentation when working on LiquiDoc templates, in favor of the following.

.Designating Alternate Includes Source Directories
****
For templates that employ the Liquid `include` tag to transclude additional template files, LiquiDoc trawls certain directories in search of the named template.

By default, LiquiDoc will check the following paths for a template with the indicated filename:

include::../_build/snippets/built/includes-dirs-list.adoc[]

Additionally, the directory of the primary template will be appended to this list, so LiquiDoc will always scan the calling template's own directory first for a matching file.

To override the default list, add the `includes_dirs` property to the `build` block.

.Example -- Custom includes paths
[source,yaml]
----
- action: parse
data: mydata.yml
builds:
- output: _build/myoutput.txt
template: _extras/mytemplate.text
includes_dirs:
- _includes
- _build/_includes
----

In the above example, assuming `mytemplate.text` contains one or more `include` tags, the directories `+++_includes/+++` and `+++_build/_includes/+++` will be checked _instead of_ the default directories.
The main template's home directory (`_extras/`) will also be checked.
****

=== Filters

LiquiDoc is proud to offer the largest set of Liquid filters available in one place.
Expand Down
7 changes: 4 additions & 3 deletions lib/liquid/tags/jekyll.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@ def render_variable(context)

# Array of directories where includes are stored
def tag_includes_dirs(context)
# context[:includes_dirs]
['_templates','_templates/liquid','_templates/liquid/ops','theme/_includes','_theme/layouts']
context.stack do
context['includes_dirs']
end
end

# Traverse includes dirs, setting paths for includes
def locate_include_file(context, file, safe)
includes_dirs = ['_templates','_templates/liquid','_templates/liquid/ops','_templates/ops','theme/_includes','theme/_layouts']
includes_dirs = self.tag_includes_dirs(context)
includes_dirs.each do |dir|
path = File.join(dir.to_s, file.to_s)
return path if File.exist?(path)
Expand Down
7 changes: 4 additions & 3 deletions lib/liquidoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@build_dir = @build_dir_def
@configs_dir = @base_dir + '_configs'
@templates_dir = @base_dir + '_templates/'
@includes_dirs_def = ['.','_templates','_templates/liquid','_templates/liquid/ops','_templates/ops','theme/_includes','_theme/layouts']
@includes_dirs_def = ['_templates','_templates/liquid','_templates/liquid/ops','_templates/ops','theme/_includes','theme/_layouts']
@includes_dirs = @includes_dirs_def
@data_dir = @base_dir + '_data/'
@data_files = nil
Expand Down Expand Up @@ -155,7 +155,8 @@ def iterate_build cfg
build.add_data!(build.variables, "vars") if build.variables
includes_dirs = @includes_dirs
includes_dirs = build.includes_dirs if build.includes_dirs
build.add_data!({:includes_dirs=>includes_dirs})
includes_dirs.unshift(File.dirname(build.template))
build.add_data!(includes_dirs: includes_dirs)
liquify(build.data, build.template, build.output) # perform the liquify operation
else # Prep & perform a direct conversion
# Delete nested data and vars objects
Expand Down Expand Up @@ -1636,7 +1637,7 @@ def to_json input
@template_file = @base_dir + n
end

opts.on("--includes PATH[,PATH]", "Paths to directories where includes (partials) can be found." ) do |n|
opts.on("--includes_dirs PATH[,PATH]", "Paths to directories where includes (partials) can be found. Overrides default directories." ) do |n|
n = n.force_array
# n.map { |p| @base_dir + p }
@includes_dirs = @includes_dirs.concat n
Expand Down
2 changes: 1 addition & 1 deletion lib/liquidoc/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Liquidoc
VERSION = "0.12.0"
VERSION = "0.12.1-rc1"
end