faml 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/benchmark/compiling.rb +1 -0
  4. data/benchmark/context.rb +1 -0
  5. data/benchmark/rendering.rb +1 -0
  6. data/benchmark/slim.rb +1 -0
  7. data/ext/attribute_builder/extconf.rb +1 -0
  8. data/faml.gemspec +1 -1
  9. data/haml_spec_test.rb +1 -0
  10. data/incompatibilities/README.md +1 -1
  11. data/incompatibilities/spec/compiler_newline_spec.md +1 -1
  12. data/incompatibilities/spec/render/attribute_spec.md +314 -28
  13. data/incompatibilities/spec/render/comment_spec.md +1 -1
  14. data/incompatibilities/spec/render/doctype_spec.md +1 -1
  15. data/incompatibilities/spec/render/element_spec.md +1 -1
  16. data/incompatibilities/spec/render/filters/cdata_spec.md +1 -1
  17. data/incompatibilities/spec/render/filters/css_spec.md +1 -1
  18. data/incompatibilities/spec/render/filters/escaped_spec.md +1 -1
  19. data/incompatibilities/spec/render/filters/javascript_spec.md +1 -1
  20. data/incompatibilities/spec/render/filters/markdown_spec.md +1 -1
  21. data/incompatibilities/spec/render/filters/plain_spec.md +2 -2
  22. data/incompatibilities/spec/render/filters/preserve_spec.md +1 -1
  23. data/incompatibilities/spec/render/helpers_spec.md +2 -2
  24. data/incompatibilities/spec/render/multiline_spec.md +2 -2
  25. data/incompatibilities/spec/render/newline_spec.md +4 -4
  26. data/incompatibilities/spec/render/plain_spec.md +1 -1
  27. data/incompatibilities/spec/render/sanitize_spec.md +2 -2
  28. data/incompatibilities/spec/render/silent_script_spec.md +1 -1
  29. data/incompatibilities/spec/render/unescape_spec.md +3 -3
  30. data/lib/faml.rb +1 -0
  31. data/lib/faml/attribute_compiler.rb +1 -0
  32. data/lib/faml/attribute_optimizer.rb +14 -3
  33. data/lib/faml/cli.rb +1 -0
  34. data/lib/faml/compiler.rb +1 -0
  35. data/lib/faml/engine.rb +1 -0
  36. data/lib/faml/error.rb +1 -0
  37. data/lib/faml/filter_compilers.rb +1 -0
  38. data/lib/faml/filter_compilers/base.rb +1 -0
  39. data/lib/faml/filter_compilers/cdata.rb +1 -0
  40. data/lib/faml/filter_compilers/coffee.rb +1 -0
  41. data/lib/faml/filter_compilers/css.rb +1 -0
  42. data/lib/faml/filter_compilers/escaped.rb +1 -0
  43. data/lib/faml/filter_compilers/javascript.rb +1 -0
  44. data/lib/faml/filter_compilers/markdown.rb +1 -0
  45. data/lib/faml/filter_compilers/plain.rb +1 -0
  46. data/lib/faml/filter_compilers/preserve.rb +1 -0
  47. data/lib/faml/filter_compilers/ruby.rb +1 -0
  48. data/lib/faml/filter_compilers/sass.rb +1 -0
  49. data/lib/faml/filter_compilers/scss.rb +1 -0
  50. data/lib/faml/filter_compilers/tilt_base.rb +1 -0
  51. data/lib/faml/helpers.rb +1 -0
  52. data/lib/faml/html.rb +1 -0
  53. data/lib/faml/newline.rb +1 -0
  54. data/lib/faml/object_ref.rb +1 -0
  55. data/lib/faml/rails_handler.rb +1 -0
  56. data/lib/faml/rails_helpers.rb +1 -0
  57. data/lib/faml/railtie.rb +1 -0
  58. data/lib/faml/ruby_syntax_checker.rb +1 -0
  59. data/lib/faml/script_end.rb +1 -0
  60. data/lib/faml/static_hash_parser.rb +37 -13
  61. data/lib/faml/stats.rb +1 -0
  62. data/lib/faml/text_compiler.rb +1 -0
  63. data/lib/faml/tilt.rb +1 -0
  64. data/lib/faml/version.rb +2 -1
  65. data/spec/compiler_newline_spec.rb +1 -0
  66. data/spec/rails/app/controllers/application_controller.rb +1 -0
  67. data/spec/rails/app/controllers/books_controller.rb +1 -0
  68. data/spec/rails/app/helpers/application_helper.rb +1 -0
  69. data/spec/rails/app/models/book.rb +1 -0
  70. data/spec/rails/config/application.rb +1 -0
  71. data/spec/rails/config/boot.rb +1 -0
  72. data/spec/rails/config/environment.rb +1 -0
  73. data/spec/rails/config/environments/development.rb +1 -0
  74. data/spec/rails/config/environments/production.rb +1 -0
  75. data/spec/rails/config/environments/test.rb +1 -0
  76. data/spec/rails/config/initializers/assets.rb +1 -0
  77. data/spec/rails/config/initializers/backtrace_silencers.rb +1 -0
  78. data/spec/rails/config/initializers/cookies_serializer.rb +1 -0
  79. data/spec/rails/config/initializers/filter_parameter_logging.rb +1 -0
  80. data/spec/rails/config/initializers/inflections.rb +1 -0
  81. data/spec/rails/config/initializers/mime_types.rb +1 -0
  82. data/spec/rails/config/initializers/secret_key_base.rb +1 -0
  83. data/spec/rails/config/initializers/session_store.rb +1 -0
  84. data/spec/rails/config/initializers/wrap_parameters.rb +1 -0
  85. data/spec/rails/config/routes.rb +1 -0
  86. data/spec/rails/db/seeds.rb +1 -0
  87. data/spec/rails/spec/requests/faml_spec.rb +1 -0
  88. data/spec/rails_helper.rb +1 -0
  89. data/spec/render/attribute_spec.rb +33 -0
  90. data/spec/render/comment_spec.rb +1 -0
  91. data/spec/render/doctype_spec.rb +1 -0
  92. data/spec/render/element_spec.rb +1 -0
  93. data/spec/render/filters/cdata_spec.rb +1 -0
  94. data/spec/render/filters/coffee_spec.rb +1 -0
  95. data/spec/render/filters/css_spec.rb +1 -0
  96. data/spec/render/filters/escaped_spec.rb +1 -0
  97. data/spec/render/filters/javascript_spec.rb +1 -0
  98. data/spec/render/filters/markdown_spec.rb +1 -0
  99. data/spec/render/filters/plain_spec.rb +1 -0
  100. data/spec/render/filters/preserve_spec.rb +1 -0
  101. data/spec/render/filters/ruby_spec.rb +1 -0
  102. data/spec/render/filters/sass_spec.rb +1 -0
  103. data/spec/render/filters/scss_spec.rb +1 -0
  104. data/spec/render/filters_spec.rb +1 -0
  105. data/spec/render/haml_comment_spec.rb +1 -0
  106. data/spec/render/helpers_spec.rb +1 -0
  107. data/spec/render/multiline_spec.rb +1 -0
  108. data/spec/render/newline_spec.rb +1 -0
  109. data/spec/render/plain_spec.rb +1 -0
  110. data/spec/render/preserve_spec.rb +1 -0
  111. data/spec/render/sanitize_spec.rb +1 -0
  112. data/spec/render/script_spec.rb +1 -0
  113. data/spec/render/silent_script_spec.rb +1 -0
  114. data/spec/render/unescape_spec.rb +1 -0
  115. data/spec/spec_helper.rb +1 -0
  116. data/spec/support/incompatibilities_generator.rb +2 -1
  117. data/spec/tilt_spec.rb +1 -0
  118. metadata +3 -3
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'find'
2
3
  require 'pathname'
3
4
  require 'haml_parser/parser'
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'haml_parser/utils'
2
3
  require 'strscan'
3
4
  require_relative 'error'
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'tilt'
2
3
  # Load tilt/haml only when haml is available
3
4
  begin
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  module Faml
2
- VERSION = '0.6.0'
3
+ VERSION = '0.6.1'
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  class LineVerifier < StandardError
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  class ApplicationController < ActionController::Base
2
3
  # Prevent CSRF attacks by raising an exception.
3
4
  # For APIs, you may want to use :null_session instead.
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  class BooksController < ApplicationController
2
3
  def hello
3
4
  end
@@ -1,2 +1,3 @@
1
+ # frozen-string-literal: true
1
2
  module ApplicationHelper
2
3
  end
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  class Book
2
3
  include ActiveModel::Model
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require File.expand_path('../boot', __FILE__)
2
3
 
3
4
  require 'rails/all'
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
3
 
3
4
  require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  # Load the Rails application.
2
3
  require File.expand_path('../application', __FILE__)
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  Rails.application.configure do
2
3
  # Settings specified here will take precedence over those in config/application.rb.
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  Rails.application.configure do
2
3
  # Settings specified here will take precedence over those in config/application.rb.
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  TestApp::Application.configure do
2
3
  # Settings specified here will take precedence over those in config/application.rb.
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Version of your assets, change this if you want to expire all your assets.
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Configure sensitive parameters which will be filtered from the log file.
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Add new inflection rules using the following format. Inflections
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Add new mime types for use in respond_to blocks:
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  version = [Rails::VERSION::MAJOR, Rails::VERSION::MINOR]
2
3
  if version == [4, 0]
3
4
  TestApp::Application.configure do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  Rails.application.config.session_store :cookie_store, key: '_test_app_session'
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # This file contains settings for ActionController::ParamsWrapper which
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  Rails.application.routes.draw do
2
3
  namespace :books do
3
4
  get :hello
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  # This file should contain all the record creation needed to seed the database with its default values.
2
3
  # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'rails_helper'
2
3
 
3
4
  RSpec.describe 'Faml with Rails', type: :request do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  ENV['RAILS_ENV'] ||= 'test'
2
3
  require 'spec_helper'
3
4
  require File.expand_path('../rails/config/environment', __FILE__)
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Attributes rendering', type: :render do
@@ -228,4 +229,36 @@ HAML
228
229
  expect(render_string('%span#baz[Faml::TestStruct.new(123)]{id: "foo"} hello')).to eq("<span class='faml_test_struct' id='baz_foo_faml_test_struct_123'>hello</span>\n")
229
230
  end
230
231
  end
232
+
233
+ context 'when old attributes and new attributes have the same key' do
234
+ it 'prefers old attributes' do
235
+ aggregate_failures do
236
+ expect(render_string('%span{foo: 1}(foo=2)')).to eq("<span foo='1'></span>\n")
237
+ expect(render_string('%span(foo=2){foo: 1}')).to eq("<span foo='1'></span>\n")
238
+ expect(render_string("- v = 2\n%span{foo: v-1}(foo=v)")).to eq("<span foo='1'></span>\n")
239
+ expect(render_string("- v = 2\n%span(foo=v){foo: v-1}")).to eq("<span foo='1'></span>\n")
240
+ expect(render_string("- h = {foo: 1}\n%span{h}(foo=2)")).to eq("<span foo='1'></span>\n")
241
+ expect(render_string("- h = {foo: 1}\n%span(foo=2){h}")).to eq("<span foo='1'></span>\n")
242
+ end
243
+ end
244
+
245
+ it 'merges class attribute' do
246
+ aggregate_failures do
247
+ expect(render_string('%span{class: 1}(class=2)')).to eq("<span class='1 2'></span>\n")
248
+ expect(render_string("- v = 2\n%span{class: v-1}(class=v)")).to eq("<span class='1 2'></span>\n")
249
+ expect(render_string("- h = {class: 1}\n%span{h}(class=2)")).to eq("<span class='1 2'></span>\n")
250
+ end
251
+ end
252
+
253
+ it 'merges id attribute' do
254
+ aggregate_failures do
255
+ expect(render_string('%span{id: 1}(id=2)')).to eq("<span id='2_1'></span>\n")
256
+ expect(render_string('%span(id=2){id: 1}')).to eq("<span id='2_1'></span>\n")
257
+ expect(render_string("- v = 2\n%span{id: v-1}(id=v)")).to eq("<span id='2_1'></span>\n")
258
+ expect(render_string("- v = 2\n%span(id=v){id: v-1}")).to eq("<span id='2_1'></span>\n")
259
+ expect(render_string("- h = {id: 1}\n%span{h}(id=2)")).to eq("<span id='2_1'></span>\n")
260
+ expect(render_string("- h = {id: 1}\n%span(id=2){h}")).to eq("<span id='2_1'></span>\n")
261
+ end
262
+ end
263
+ end
231
264
  end
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Comment rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Doctype rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Element rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'CDATA filter rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'CoffeeScript filter rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'CSS filter rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Escaped filter rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'JavaScript filter rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Markdown filter rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Plain filter rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Preserve filter rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Ruby filter rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'SASS filter rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'SCSS filter rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'filter rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Haml comment rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe Faml::Helpers, type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Multiline rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Newline with > and <', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Plain rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Preserve rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Sanitize rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Script rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'SilentScript rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Unescape rendering', type: :render do
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'simplecov'
2
3
  require 'coveralls'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'pathname'
2
3
  require 'singleton'
3
4
  require 'hamlit/engine'
@@ -100,7 +101,7 @@ EOS
100
101
  def render_input_title(options)
101
102
  title = 'Input'
102
103
  unless options.empty?
103
- title << " (with options=#{options.inspect})"
104
+ title += " (with options=#{options.inspect})"
104
105
  end
105
106
  title
106
107
  end
@@ -1,3 +1,4 @@
1
+ # frozen-string-literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Tilt integration' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki
@@ -226,14 +226,14 @@ dependencies:
226
226
  requirements:
227
227
  - - ">="
228
228
  - !ruby/object:Gem::Version
229
- version: '3'
229
+ version: '3.3'
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - ">="
235
235
  - !ruby/object:Gem::Version
236
- version: '3'
236
+ version: '3.3'
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: rubocop
239
239
  requirement: !ruby/object:Gem::Requirement