serbea 0.10.5 → 0.11.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,9 +3,7 @@ require "bridgetown-core"
3
3
 
4
4
  module Bridgetown
5
5
  class SerbeaView < ERBView
6
- alias_method :_erb_capture, :capture
7
6
  include Serbea::Helpers
8
- alias_method :capture, :_erb_capture
9
7
 
10
8
  def partial(partial_name, options = {}, &block)
11
9
  options.merge!(options[:locals]) if options[:locals]
@@ -29,7 +27,7 @@ module Bridgetown
29
27
  # Logic to do the Serbea content conversion.
30
28
  #
31
29
  # @param content [String] Content of the file (without front matter).
32
- # @params convertible [Bridgetown::Page, Bridgetown::Document, Bridgetown::Layout]
30
+ # @param convertible [Bridgetown::Page, Bridgetown::Document, Bridgetown::Layout]
33
31
  # The instantiated object which is processing the file.
34
32
  #
35
33
  # @return [String] The converted content.
@@ -20,10 +20,10 @@ module Serbea
20
20
  end
21
21
 
22
22
  def helper(name, &helper_block)
23
- self.class.define_method(name) do |*args, &block|
23
+ self.class.define_method(name) do |*args, **kwargs, &block|
24
24
  previous_buffer_state = @_erbout
25
25
  @_erbout = Serbea::OutputBuffer.new
26
- result = helper_block.call(*args, &block)
26
+ result = helper_block.call(*args, **kwargs, &block)
27
27
  @_erbout = previous_buffer_state
28
28
 
29
29
  result.is_a?(String) ? result.html_safe : result
@@ -3,6 +3,11 @@ require "active_support/core_ext/object/blank"
3
3
 
4
4
  module Serbea
5
5
  class Pipeline
6
+ # Exec the pipes!
7
+ # @param template [String]
8
+ # @param locals [Hash]
9
+ # @param include_helpers [Module]
10
+ # @param kwargs [Hash]
6
11
  def self.exec(template, locals = {}, include_helpers: nil, **kwargs)
7
12
  anon = Class.new do
8
13
  include Serbea::Helpers
@@ -24,9 +29,12 @@ module Serbea
24
29
  pipeline_obj.output
25
30
  end
26
31
 
32
+ # @param processor [Proc]
27
33
  def self.output_processor=(processor)
28
34
  @output_processor = processor
29
35
  end
36
+
37
+ # @return [Proc]
30
38
  def self.output_processor
31
39
  @output_processor ||= lambda do |input|
32
40
  (!input.html_safe? && self.autoescape) ? ERB::Util.h(input) : input.html_safe
@@ -40,11 +40,29 @@ module Serbea
40
40
  end
41
41
 
42
42
  Serbea::TemplateEngine.directive :form, ->(code, buffer) do
43
- buffer << "{%= form_with model:"
43
+ model_name, space, params = code.lstrip.partition(%r(\s)m)
44
+ model_name.chomp!(",")
45
+ model_name = "#{model_name}," unless params.lstrip.start_with?("do", "{")
46
+
47
+ buffer << "{%= form_with model: "
48
+ buffer << model_name << " #{params}"
49
+ buffer << " %}"
50
+ end
51
+
52
+ Serbea::TemplateEngine.directive :frame, ->(code, buffer) do
53
+ buffer << "{%= turbo_frame_tag "
44
54
  buffer << code
45
55
  buffer << " %}"
46
56
  end
47
57
 
58
+ %i(append prepend update replace remove).each do |action|
59
+ Serbea::TemplateEngine.directive action, ->(code, buffer) do
60
+ buffer << "{%= turbo_stream.#{action} "
61
+ buffer << code
62
+ buffer << " %}"
63
+ end
64
+ end
65
+
48
66
  Serbea::TemplateEngine.directive :_, ->(code, buffer) do
49
67
  tag_name, space, params = code.lstrip.partition(%r(\s)m)
50
68
 
@@ -44,6 +44,11 @@ module Serbea
44
44
  pieces.last << ")"
45
45
  buffer << "{%= render#{pieces.join(" ")} %}"
46
46
  end
47
+ end,
48
+ "`" => ->(code, buffer) do
49
+ buffer << "{%= %`"
50
+ buffer << code.gsub(%r("([^\\]?)\#{(.*?)}"), "\"\\1\#{h(\\2)}\"")
51
+ buffer << ".strip %}"
47
52
  end
48
53
  }
49
54
  end
@@ -167,7 +172,7 @@ module Serbea
167
172
  string = buff
168
173
  buff = ""
169
174
  until string.empty?
170
- text, code, string = string.partition(/{%@([a-z_]+)?(.*?)%}/m)
175
+ text, code, string = string.partition(/{%@([a-z_`]+)?(.*?)%}/m)
171
176
 
172
177
  buff << text
173
178
  if code.length > 0
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Serbea
2
- VERSION = "0.10.5"
2
+ VERSION = "0.11.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serbea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.5
4
+ version: 0.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-09 00:00:00.000000000 Z
11
+ date: 2021-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '13.0'
83
- description:
83
+ description:
84
84
  email: maintainers@bridgetownrb.com
85
85
  executables: []
86
86
  extensions: []
@@ -88,8 +88,35 @@ extra_rdoc_files: []
88
88
  files:
89
89
  - ".gitignore"
90
90
  - Gemfile
91
+ - LICENSE.txt
91
92
  - README.md
92
93
  - Rakefile
94
+ - docs/.gitignore
95
+ - docs/Gemfile
96
+ - docs/bridgetown.config.yml
97
+ - docs/frontend/javascript/index.js
98
+ - docs/frontend/styles/index.scss
99
+ - docs/package.json
100
+ - docs/plugins/builders/.keep
101
+ - docs/plugins/site_builder.rb
102
+ - docs/src/404.html
103
+ - docs/src/_components/footer.liquid
104
+ - docs/src/_components/head.liquid
105
+ - docs/src/_components/navbar.liquid
106
+ - docs/src/_data/site_metadata.yml
107
+ - docs/src/_layouts/default.liquid
108
+ - docs/src/_layouts/home.liquid
109
+ - docs/src/_layouts/page.liquid
110
+ - docs/src/_layouts/post.liquid
111
+ - docs/src/favicon.ico
112
+ - docs/src/images/.keep
113
+ - docs/src/images/serbea-logomark.svg
114
+ - docs/src/images/serbea-logotype.svg
115
+ - docs/src/index.md
116
+ - docs/start.js
117
+ - docs/sync.js
118
+ - docs/webpack.config.js
119
+ - docs/yarn.lock
93
120
  - lib/serbea.rb
94
121
  - lib/serbea/bridgetown_support.rb
95
122
  - lib/serbea/helpers.rb
@@ -103,7 +130,7 @@ homepage: https://github.com/bridgetownrb/serbea
103
130
  licenses:
104
131
  - MIT
105
132
  metadata: {}
106
- post_install_message:
133
+ post_install_message:
107
134
  rdoc_options: []
108
135
  require_paths:
109
136
  - lib
@@ -118,8 +145,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
145
  - !ruby/object:Gem::Version
119
146
  version: '0'
120
147
  requirements: []
121
- rubygems_version: 3.0.6
122
- signing_key:
148
+ rubygems_version: 3.2.3
149
+ signing_key:
123
150
  specification_version: 4
124
151
  summary: Similar to ERB, Except Awesomer
125
152
  test_files: []