Skip to content

Commit

Permalink
Refactor indent filter, it now accepts a param indicating the number of
Browse files Browse the repository at this point in the history
spaces to indent the content.
  • Loading branch information
fabianrbz committed Jul 18, 2024
1 parent c88801a commit 5317eed
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
--header "accept: application/json" \
--header "Content-Type: application/json" \
--data '
{{ include.presenter.data | json_prettify | indent | indent }}
{{ include.presenter.data | json_prettify | indent: 4 }}
'
{% endhighlight %}
2 changes: 1 addition & 1 deletion app/_includes/components/entity_example/format/deck.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
_format_version: "3.0"
{{ include.presenter.entity }}:
-
{{ include.presenter.data | indent }}
{{ include.presenter.data | indent: 2 }}
{% endhighlight %}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
--header "accept: application/json" \
--header "Content-Type: application/json" \
--data '
{{ include.presenter.data | json_prettify | indent | indent }}
{{ include.presenter.data | json_prettify | indent: 4 }}
'
{% endhighlight %}
4 changes: 2 additions & 2 deletions app/_plugins/filters/indent.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

module IndentFilter
def indent(input)
def indent(input, spaces)
input
.gsub("\n</code>", '</code>')
.split("\n")
.map { |l| l.prepend(' ') }
.map { |l| l.prepend(' ' * spaces.to_i) }
.join("\n")
end
end
Expand Down

0 comments on commit 5317eed

Please sign in to comment.