Skip to content

Commit

Permalink
Fix wording
Browse files Browse the repository at this point in the history
  • Loading branch information
eagletmt committed Dec 6, 2015
1 parent 66071e9 commit ed665a7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -18,7 +18,7 @@
- https://github.com/eagletmt/faml/pull/41

## 0.6.3 (2015-11-22)
- Remove duplicated class in Ruby attribute case
- Remove duplicated class in runtime attribute case
- `%span.foo{h}` where `h = { class: 'foo bar' }` now renders `<span class='bar foo'></span>` .
- `%span.foo{class: 'foo bar'}` renders `<span class='bar foo'></span>` since v0.2.12 .

Expand Down
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -90,7 +90,7 @@ You have to set `Faml::Engine.options[:extend_helpers] = true` to use `preserve`
### Others
If you find other incompatibility, please report it to me :-p.

## Why faml is faster?
## Why is faml faster?
### Temple backend
I use [temple](https://github.com/judofyr/temple) to achieve faster template rendering.
It's used by [slim](https://github.com/slim-template/slim) template language & engine which is known as fast.
Expand Down Expand Up @@ -120,18 +120,18 @@ The runtime hash merging is implemented by C extension in faml.
Internally, attributes are categolized into three types.

1. Static attributes
- Both the key and the value are literal.
- Both the key and the value are static.
- Compiled into string literals.
- Fastest.
- e.g. `%input{checked: false}`
2. Dynamic attributes
- The key is literal but the value isn't.
- The key is static but the value isn't.
- The key is compiled into string literal. The value is interpolated at run-time.
- Relatively fast.
- e.g. `%input{checked: helper_method(@record)}`
3. Ruby attributes
- Both the key and the value are non-literal expression.
- The attributes are stringified at run-time.
3. Runtime attributes
- Both the key and the value are non-static expression.
- The attributes are stringified at runtime.
- Slow.
- e.g. `%input{helper_method(@record)}`

Expand Down
10 changes: 5 additions & 5 deletions lib/faml/stats.rb
Expand Up @@ -13,7 +13,7 @@ class Stats
:dynamic_attribute_count,
:dynamic_attribute_with_data_count,
:dynamic_attribute_with_newline_count,
:ruby_attribute_count,
:runtime_attribute_count,
:object_reference_count,
:multi_attribute_count,
:ast_types
Expand Down Expand Up @@ -133,7 +133,7 @@ def collect_attribute_info(info, ast)
if call_ast.type == :send && call_ast.children[0].nil? && call_ast.children[1] == :call && !call_ast.children[3].nil?
info.multi_attribute_count += 1
else
info.ruby_attribute_count += 1
info.runtime_attribute_count += 1
end
end
end
Expand All @@ -142,16 +142,16 @@ def collect_attribute_info(info, ast)
def report_attribute_stats(info)
static = info.static_attribute_count
dynamic = info.dynamic_attribute_count + info.dynamic_attribute_with_data_count + info.dynamic_attribute_with_newline_count
ruby = info.ruby_attribute_count + info.multi_attribute_count + info.object_reference_count
total = static + dynamic + ruby
runtime = info.runtime_attribute_count + info.multi_attribute_count + info.object_reference_count
total = static + dynamic + runtime
puts 'Attribute stats'
printf(" Empty attributes: %d\n", info.empty_attribute_count)
printf(" Attributes with id or class only: %d\n", info.static_id_or_class_attribute_count)
printf(" Static attributes: %d (%.2f%%)\n", static, static * 100.0 / total)
printf(" Dynamic attributes: %d (%.2f%%)\n", dynamic, dynamic * 100.0 / total)
printf(" with data: %d\n", info.dynamic_attribute_with_data_count)
printf(" with newline: %d\n", info.dynamic_attribute_with_newline_count)
printf(" Ruby attributes: %d (%.2f%%)\n", ruby, ruby * 100.0 / total)
printf(" Runtime attributes: %d (%.2f%%)\n", runtime, runtime * 100.0 / total)
printf(" with multiple arguments: %d\n", info.multi_attribute_count)
printf(" with object reference: %d\n", info.object_reference_count)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/compiler_newline_spec.rb
Expand Up @@ -190,7 +190,7 @@ module LineVerifierHelper
HAML
end

it 'keeps newlines in ruby attributes' do
it 'keeps newlines in runtime attributes' do
expect { render_string(<<HAML) }.to raise_error(LineVerifier, raised_at(2))
%span{[1,
raise(LineVerifier)]}
Expand Down

0 comments on commit ed665a7

Please sign in to comment.