-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bba8f28
commit 96f2dce
Showing
4 changed files
with
96 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
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,23 @@ | ||
{% comment %}{% raw %}<!-- | ||
Includes the specified lines from an include file. | ||
|
||
Usage: | ||
{% include includelines filename=PATH start=INT count=INT %} | ||
|
||
filename: path to file under _includes | ||
start: first line to include, starting at 1 | ||
count: number of lines to include | ||
|
||
Example: | ||
|
||
{% include includelines filename='src/HelloWorld.java' start=10 count=5 %} | ||
|
||
-->{% endraw %}{% endcomment %} | ||
|
||
{% capture filecontent %} | ||
{% include {{include.filename}} %} | ||
{% endcapture %} | ||
|
||
{% assign lines = filecontent | newline_to_br | split: '<br />' %} | ||
|
||
{% for line in lines offset:{{include.start}} limit:{{include.count}} %}{{ line }}{% endfor %} |
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,60 @@ | ||
{% comment %}{% raw %}<!-- | ||
Includes a method snippet from an include file of C / Java type language. | ||
|
||
Usage: | ||
{% include includemethod filename=PATH method=STRING [before=INT] [after=INT] %} | ||
|
||
filename: path to file under _includes | ||
method: method or other string to match | ||
before: lines to include before the start of the method | ||
after: lines to include after the method's final closing bracket | ||
|
||
Includes lines starting at where the string 'method' is found, and continues | ||
until a matching curly bracket is found. The before / after arguments can be | ||
used to include further lines. | ||
|
||
Example: | ||
|
||
{% include includemethod filename='src/HelloWorld.java' method='test()' before=2 after=1 %} | ||
|
||
-->{% endraw %}{% endcomment %}{% capture unused %} | ||
|
||
{% capture filecontent %} | ||
{% include {{include.filename}} %} | ||
{% endcapture %} | ||
|
||
{% assign start = 0 %} | ||
{% assign braketlevel = 0 %} | ||
|
||
{% assign lines = filecontent | newline_to_br | split: '<br />' %} | ||
{% for line in lines %} | ||
{% if line contains {{include.method}} %} | ||
{% assign start = forloop.index | minus: 1 %} | ||
{% endif %} | ||
|
||
{% if start > 0 %} | ||
{%if line contains '{' %} | ||
{% assign braketlevel = braketlevel | plus: 1 %} | ||
{% endif %} | ||
|
||
{% if line contains '}' %} | ||
{% assign braketlevel = braketlevel | minus: 1 %} | ||
{% endif %} | ||
|
||
{% if braketlevel == 0 %} | ||
{% assign count = forloop.index | minus: start %} | ||
{% break %} | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
|
||
{% if include.before %} | ||
{% assign start = start | minus: include.before %} | ||
{% assign count = count | plus: include.before %} | ||
{% endif %} | ||
|
||
{% if include.after %} | ||
{% assign count = count | plus: include.after %} | ||
{% endif %} | ||
|
||
{% endcapture %}{% assign unused = nil %}{% for line in lines offset:start limit:count %}{{ line }}{% endfor %} |
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,12 @@ | ||
--- | ||
hidden: true | ||
--- | ||
|
||
|
||
```python | ||
{% include includelines filename='testfile.py' method='main()' start=1 count=3 %} | ||
``` | ||
|
||
{% include includemethod filename='testfile.py' method='main()' before=0 after=3 %} | ||
|
||
|