Skip to content

Commit 8b9c62d

Browse files
jmerleThibaut
authored andcommitted
Add Handlebars.js documentation
1 parent 62e07e4 commit 8b9c62d

File tree

8 files changed

+93
-0
lines changed

8 files changed

+93
-0
lines changed

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ credits = [
310310
'GruntJS Team',
311311
'MIT',
312312
'https://github.com/gruntjs/grunt-docs/blob/master/package.json#L10'
313+
], [
314+
'Handlebars',
315+
'2011-2017 Yehuda Katz',
316+
'MIT',
317+
'https://raw.githubusercontent.com/wycats/handlebars.js/master/LICENSE'
313318
], [
314319
'Haskell',
315320
'The University of Glasgow',

assets/stylesheets/pages/_simple.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
._flow,
2828
._gnu,
2929
._grunt,
30+
._handlebars,
3031
._haxe,
3132
._immutable,
3233
._influxdata,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module Docs
2+
class Handlebars
3+
class CleanHtmlFilter < Filter
4+
def call
5+
# Remove the t-shirt shop advertisement
6+
css('#callout').remove
7+
8+
# The title filter is used to add titles to pages without one, remove original headers
9+
css('h1').remove
10+
11+
# Remove the link to the issue tracker
12+
css('.issue-tracker').remove
13+
14+
css('pre').each do |node|
15+
# Remove nested nodes inside pre tags
16+
node.content = node.content
17+
18+
# Add syntax highlighting
19+
node['data-language'] = 'html'
20+
end
21+
22+
# Transform 'Learn More' links to headers in the "Getting Started" part of the homepage
23+
# If this step is skipped, that section looks cluttered with 4 sub-sections without any dividers
24+
css('#getting-started + .contents a.more-info').each do |node|
25+
clone = node.clone
26+
27+
# Move it to the top of the sub-section
28+
node.parent.prepend_child(clone)
29+
30+
# Turn it into a header
31+
clone.name = 'h3'
32+
33+
# Remove the "Learn More: " part
34+
clone.content = clone.content[12..-1]
35+
end
36+
37+
# Remove class attributes from div elements to reduce file size
38+
css('div').remove_attr('class')
39+
40+
doc
41+
end
42+
end
43+
end
44+
end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Docs
2+
class Handlebars
3+
class EntriesFilter < Docs::EntriesFilter
4+
def get_name
5+
subpath[0..-6].titleize
6+
end
7+
8+
def get_type
9+
name
10+
end
11+
12+
def additional_entries
13+
css('h2, h3').to_a.map do |node|
14+
[node.content.strip, node['id'], root_page? ? 'Manual' : nil]
15+
end
16+
end
17+
end
18+
end
19+
end

lib/docs/scrapers/handlebars.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module Docs
2+
class Handlebars < UrlScraper
3+
self.name = 'Handlebars.js'
4+
self.slug = 'handlebars'
5+
self.type = 'handlebars'
6+
self.release = '4.0.11'
7+
self.base_url = 'https://handlebarsjs.com/'
8+
self.links = {
9+
home: 'https://handlebarsjs.com/',
10+
code: 'https://github.com/wycats/handlebars.js/'
11+
}
12+
13+
html_filters.push 'handlebars/entries', 'handlebars/clean_html', 'title'
14+
15+
options[:container] = '#contents'
16+
options[:root_title] = 'Handlebars.js'
17+
18+
options[:attribution] = <<-HTML
19+
&copy; 2011-2017 by Yehuda Katz<br>
20+
Licensed under the MIT License.
21+
HTML
22+
end
23+
end

public/icons/docs/handlebars/16.png

1.1 KB
Loading
4.12 KB
Loading

public/icons/docs/handlebars/SOURCE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/yahoo/formatjs-site/tree/master/public/img

0 commit comments

Comments
 (0)