1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00
stedolan-jq/docs/templates/manual.liquid

121 lines
4.8 KiB
Plaintext
Raw Normal View History

2012-09-18 17:51:53 +01:00
<!DOCTYPE html>
<html lang="en">
{% include "shared/head" %}
2012-09-18 17:51:53 +01:00
<body id="{{slug}}" data-spy="scroll" data-target="#navcolumn" data-offset="100">
2012-09-18 23:17:27 +01:00
{% include "shared/header" %}
2012-09-18 17:51:53 +01:00
<div class="container">
<div class="row">
<div class="affix" id="navcolumn">
2012-09-18 17:51:53 +01:00
<h4>Contents</h4>
<ul class="nav nav-pills nav-stacked">
{% for section in sections %}
<li>
2012-09-18 17:51:53 +01:00
<a href="#{{section.title | sanitize}}">{{section.title}}</a>
</li>
{% endfor %}
</ul>
<form class="form-group">
2012-09-18 17:51:53 +01:00
<script type="text/javascript">
var section_map = {
{% for section in sections %}
{% for entry in section.entries %}
{{entry.title | json}} : {{entry.title | sanitize | json}},
{% endfor %}
{{section.title | json}} : {{section.title | sanitize | json}}
{% unless forloop.last %},{% endunless %}
{% endfor %}
};
var section_names = $.map(section_map, function(v,k){return k});
$(function(){
$('#searchbox').typeahead({source: section_names})
$('#searchbox').change(function() {
if ($(this).val() in section_map) {
location.hash = '#' + section_map[$(this).val()];
}
});
});
// add "Run" button to execute examples on jqplay.org
$(function() {
$.each($('table.manual-example'), function(index, value) {
$value = $(value)
var j = $value.find('tr:nth-child(2) td:first').text();
var q = $value.find('.jqprogram').text().replace(/^jq /, '').replace(/^'(.+)'$/, '$1');
var url = 'https://jqplay.org/jq?q=' + encodeURIComponent(q) +'&j=' + encodeURIComponent(j)
var $last_tr = $value.find('tr:last');
$last_tr.after('<tr><th><a href="' + url + '" class="btn btn-primary btn-sm">Run</a></th><th></th></tr><tr><th></th><th></th></tr>');
});
});
2012-09-18 17:51:53 +01:00
</script>
<input type="text"
class="form-control"
placeholder="Search"
autocomplete="off"
id="searchbox">
2012-09-18 17:51:53 +01:00
</form>
</div>
<div id="manualcontent">
2012-09-18 17:51:53 +01:00
<h1>{{headline}}</h1>
{{ history | markdownify }}
2012-09-18 23:17:27 +01:00
{{ body | markdownify }}
2012-09-18 17:51:53 +01:00
{% for section in sections %}
<section id="{{section.title | sanitize}}">
<h2>{{section.title}}</h2>
{{section.body | markdownify}}
{% for entry in section.entries %}
<section id="{{entry.title | sanitize}}">
<h3>
{{entry.title | markdownify}}
{% if entry.subtitle %}<small>{{entry.subtitle}}</small>{% endif %}
</h3>
{{entry.body | markdownify}}
{% if entry.examples %}
<div>
{% capture exampleID %}{{ "" | unique }}{% endcapture %}
<a data-toggle="collapse" href="#example{{exampleID}}">
<i class="glyphicon glyphicon-chevron-right"></i>
2012-09-18 17:51:53 +01:00
{% if entry.examples[1] %}Examples{%else%}Example{%endif%}
</a>
<div id="example{{exampleID}}" class="collapse">
2012-09-18 17:51:53 +01:00
{% for example in entry.examples %}
<table class="manual-example">
2014-12-21 02:20:28 +09:00
<tr><th></th><td class="jqprogram">jq '{{example.program | escape}}'</td></tr>
<tr><th>Input</th><td>{{example.input | escape}}</td></tr>
2012-09-18 17:51:53 +01:00
{% unless example.output[0] %}
<tr>
<th>Output</th>
<td><i>none</i></td>
</tr>
{% endunless %}
{% for output in example.output %}
<tr>
{% if forloop.index == 1 %}
<th>Output</th>
{% else %}
<th></th>
{% endif %}
2014-12-21 02:20:28 +09:00
<td>{{output | escape}}</td>
2012-09-18 17:51:53 +01:00
</tr>
{% endfor %}
2012-09-18 17:51:53 +01:00
</table>
{% endfor %}
</div>
</div>
{% endif %}
</section>
{% endfor %}
</section>
{% endfor %}
</div>
</div>
</div>
{% include "shared/footer" %}
</body>
2012-09-18 17:51:53 +01:00
</html>