source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/object_ref.rb | Ruby | mit | 185 | master | 1,064 | # frozen_string_literal: true
module Faml
module ObjectRef
class << self
def render(ref = nil, prefix = nil, *)
h = {}
if ref.nil?
return h
end
c = class_name(ref)
i = "#{c}_#{id(ref) || 'new'}"
if prefix
c = "#{prefix}_#{c}"
i = ... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/tilt.rb | Ruby | mit | 185 | master | 551 | # frozen_string_literal: true
require 'tilt'
# Load tilt/haml only when haml is available
begin
require 'haml'
rescue LoadError
else
require 'tilt/haml'
end
require_relative 'engine'
module Faml
class Tilt < Tilt::Template
def prepare
filename = nil
if file
filename = File.expand_path(fil... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/attribute_compiler.rb | Ruby | mit | 185 | master | 2,825 | # frozen_string_literal: true
require_relative 'attribute_optimizer'
require_relative 'object_ref'
module Faml
class AttributeCompiler
def compile(ast)
if !ast.object_ref && !ast.old_attributes && !ast.new_attributes
return compile_static_id_and_class(ast.static_id, ast.static_class)
end
... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/ruby_syntax_checker.rb | Ruby | mit | 185 | master | 211 | # frozen_string_literal: true
require 'ripper'
module Faml
class RubySyntaxChecker < Ripper
class Error < StandardError
end
private
def on_parse_error(*)
raise Error
end
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/html.rb | Ruby | mit | 185 | master | 1,960 | # frozen_string_literal: true
require 'faml/attribute_builder'
module Faml
class Html < Temple::HTML::Fast
# Override temple's default
options[:format] = :html
options[:attr_quote] = "'"
def on_haml_tag(name, self_closing, attrs, content = nil)
name = name.to_s
closed = self_closing && (... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/text_compiler.rb | Ruby | mit | 185 | master | 1,846 | # frozen_string_literal: true
require 'haml_parser/utils'
require 'strscan'
require_relative 'error'
module Faml
class TextCompiler
class InvalidInterpolation < Error
end
def initialize(escape_html: true)
@escape_html = escape_html
end
def compile(text, lineno, escape_html: @escape_html)
... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/rails_helpers.rb | Ruby | mit | 185 | master | 204 | # frozen_string_literal: true
require_relative 'helpers'
module Faml
# Don't use these methods!
module RailsHelpers
def preserve(input)
Helpers.preserve(input).html_safe
end
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/stats.rb | Ruby | mit | 185 | master | 5,471 | # frozen_string_literal: true
require 'find'
require 'pathname'
require 'haml_parser/parser'
require_relative 'static_hash_parser'
module Faml
class Stats
Info = Struct.new(
:empty_attribute_count,
:static_attribute_count,
:static_id_or_class_attribute_count,
:dynamic_attribute_count,
... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/cli.rb | Ruby | mit | 185 | master | 1,899 | # frozen_string_literal: true
require_relative '../faml'
require 'thor'
module Faml
class CLI < Thor
package_name 'faml'
desc 'render FILE', 'Render haml template'
option :format, type: :string, default: :html, desc: 'HTML format'
option :extend_helpers, type: :boolean, default: false, desc: 'Extend... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/rails_handler.rb | Ruby | mit | 185 | master | 278 | # frozen_string_literal: true
module Faml
class RailsHandler
def call(template)
Engine.new(
use_html_safe: true,
generator: Temple::Generators::RailsOutputBuffer,
filename: template.identifier,
).call(template.source)
end
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/error.rb | Ruby | mit | 185 | master | 239 | # frozen_string_literal: true
module Faml
class Error < StandardError
attr_accessor :lineno
def initialize(message, lineno)
super(message)
@lineno = lineno
end
end
class UnparsableRubyCode < Error
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/engine.rb | Ruby | mit | 185 | master | 694 | # frozen_string_literal: true
require 'haml_parser/parser'
require 'temple'
require_relative 'compiler'
require_relative 'html'
require_relative 'newline'
require_relative 'script_end'
module Faml
class Engine < Temple::Engine
define_options(
generator: Temple::Generators::ArrayBuffer,
filename: nil,... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers.rb | Ruby | mit | 185 | master | 1,040 | # frozen_string_literal: true
require_relative 'error'
module Faml
module FilterCompilers
class NotFound < Error
def initialize(name)
super("Unable to find compiler for #{name}", nil)
@name = name
end
end
def self.compilers
@compilers ||= {}
end
def self.regist... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/attribute_optimizer.rb | Ruby | mit | 185 | master | 2,896 | # frozen_string_literal: true
require 'faml/attribute_builder'
require_relative 'error'
require_relative 'ruby_syntax_checker'
require_relative 'static_hash_parser'
module Faml
class AttributeOptimizer
def try_optimize(old_attributes, new_attributes, static_id, static_class)
parser = StaticHashParser.new
... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/railtie.rb | Ruby | mit | 185 | master | 327 | # frozen_string_literal: true
module Faml
class Railtie < ::Rails::Railtie
initializer :faml do
require_relative 'rails_handler'
ActionView::Template.register_template_handler(:haml, Faml::RailsHandler.new)
ActionView::Template.register_template_handler(:faml, Faml::RailsHandler.new)
end
e... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/escaped.rb | Ruby | mit | 185 | master | 594 | # frozen_string_literal: true
require_relative 'base'
module Faml
module FilterCompilers
class Escaped < Base
include Temple::Utils
def compile(ast)
temple = [:multi, [:newline]]
compile_texts(temple, ast.lineno, ast.texts)
temple << [:static, "\n"]
escape_code = Temp... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/scss.rb | Ruby | mit | 185 | master | 417 | # frozen_string_literal: true
require_relative 'tilt_base'
module Faml
module FilterCompilers
class Scss < TiltBase
def compile(ast)
temple = [:multi, [:static, "\n"], [:newline]]
compile_with_tilt(temple, 'scss', ast, indent_width: 2)
temple << [:static, "\n"]
[:haml, :tag,... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/preserve.rb | Ruby | mit | 185 | master | 667 | # frozen_string_literal: true
require_relative 'base'
module Faml
module FilterCompilers
class Preserve < Base
include Temple::Utils
def compile(ast)
temple = [:multi, [:newline]]
# I don't know why only :preserve filter keeps the last empty lines.
compile_texts(temple, ast.l... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/css.rb | Ruby | mit | 185 | master | 408 | # frozen_string_literal: true
require_relative 'base'
module Faml
module FilterCompilers
class Css < Base
def compile(ast)
temple = [:multi, [:static, "\n"], [:newline]]
compile_texts(temple, ast.lineno, ast.texts, tab_width: 2)
temple << [:static, "\n"]
[:haml, :tag, 'style... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/plain.rb | Ruby | mit | 185 | master | 301 | # frozen_string_literal: true
require_relative 'base'
module Faml
module FilterCompilers
class Plain < Base
def compile(ast)
temple = [:multi, [:newline]]
compile_texts(temple, ast.lineno, ast.texts)
temple
end
end
register(:plain, Plain)
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/markdown.rb | Ruby | mit | 185 | master | 385 | # frozen_string_literal: true
require_relative 'tilt_base'
module Faml
module FilterCompilers
class Markdown < TiltBase
def need_newline?
false
end
def compile(ast)
temple = [:multi, [:newline]]
compile_with_tilt(temple, 'markdown', ast)
temple << [:static, "\n"... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/base.rb | Ruby | mit | 185 | master | 1,041 | # frozen_string_literal: true
require_relative '../text_compiler'
module Faml
module FilterCompilers
class Base
def need_newline?
true
end
protected
def compile_texts(temple, lineno, texts, tab_width: 0, keep_last_empty_lines: false)
tabs = ' ' * tab_width
n = 0
... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/cdata.rb | Ruby | mit | 185 | master | 363 | # frozen_string_literal: true
require_relative 'base'
module Faml
module FilterCompilers
class Cdata < Base
def compile(ast)
temple = [:multi, [:static, "<![CDATA[\n"], [:newline]]
compile_texts(temple, ast.lineno, ast.texts, tab_width: 4)
temple << [:static, "\n]]>"]
end
... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/javascript.rb | Ruby | mit | 185 | master | 444 | # frozen_string_literal: true
require_relative 'base'
module Faml
module FilterCompilers
class Javascript < Base
def compile(ast)
temple = [:multi, [:static, "\n"], [:newline]]
compile_texts(temple, ast.lineno, ast.texts, tab_width: 2)
temple << [:static, "\n"]
[:haml, :tag,... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/tilt_base.rb | Ruby | mit | 185 | master | 1,152 | # frozen_string_literal: true
require 'temple'
require 'tilt'
require_relative 'base'
module Faml
module FilterCompilers
class TiltBase < Base
include Temple::Utils
def self.render_with_tilt(name, source, indent_width: 0)
text = ::Tilt["t.#{name}"].new { source }.render
indent = ' ' ... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/ruby.rb | Ruby | mit | 185 | master | 325 | # frozen_string_literal: true
require_relative 'base'
module Faml
module FilterCompilers
class Ruby < Base
def need_newline?
false
end
def compile(ast)
[:multi, [:newline], [:code, strip_last_empty_lines(ast.texts).join("\n")]]
end
end
register(:ruby, Ruby)
end... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/sass.rb | Ruby | mit | 185 | master | 417 | # frozen_string_literal: true
require_relative 'tilt_base'
module Faml
module FilterCompilers
class Sass < TiltBase
def compile(ast)
temple = [:multi, [:static, "\n"], [:newline]]
compile_with_tilt(temple, 'sass', ast, indent_width: 2)
temple << [:static, "\n"]
[:haml, :tag,... |
github | eagletmt/faml | https://github.com/eagletmt/faml | lib/faml/filter_compilers/coffee.rb | Ruby | mit | 185 | master | 440 | # frozen_string_literal: true
require_relative 'tilt_base'
module Faml
module FilterCompilers
class Coffee < TiltBase
def compile(ast)
temple = [:multi, [:static, "\n"], [:newline]]
compile_with_tilt(temple, 'coffee', ast, indent_width: 2)
temple << [:static, "\n"]
[:haml, :... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/tilt_spec.rb | Ruby | mit | 185 | master | 762 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Tilt integration' do
def tilt(str)
Tilt.new('spec.haml') { str }
end
it 'renders with faml' do
expect(Tilt['spec.haml']).to equal(Faml::Tilt)
end
it 'renders' do
expect(tilt('%span= 1+2').render).to eq("<span>3</span>\n")
end... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/spec_helper.rb | Ruby | mit | 185 | master | 2,165 | # frozen_string_literal: true
require 'simplecov'
require 'coveralls'
SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter,
]
SimpleCov.start do
add_filter File.dirname(__FILE__)
end
require 'faml'
module RenderSpecHelper
if ENV['GENERATE_INCOMPATIBILITIES'] == '1'
... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/compiler_newline_spec.rb | Ruby | mit | 185 | master | 4,310 | # frozen_string_literal: true
require 'spec_helper'
class LineVerifier < StandardError
def initialize
super("raised at #{caller_locations(1, 1)[0].lineno}")
end
end
module LineVerifierHelper
extend RSpec::Matchers::DSL
matcher :raised_at do |expected|
match do |actual|
actual == "raised at #{ex... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/rails/Rakefile | Ruby | mit | 185 | master | 279 | # frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/rails/app/controllers/books_controller.rb | Ruby | mit | 185 | master | 232 | # frozen_string_literal: true
class BooksController < ApplicationController
def hello
end
def with_variables
@book = Book.new(params.permit(:title))
end
def object_ref
@book = Book.new(id: params[:id])
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/rails/config/application.rb | Ruby | mit | 185 | master | 310 | # frozen_string_literal: true
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module TestApp
class Application < Rails::Application
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/rails/config/routes.rb | Ruby | mit | 185 | master | 400 | # frozen_string_literal: true
Rails.application.routes.draw do
namespace :books do
get :hello
get :with_variables
get :with_capture
get :escaped
get :preserve
get :html_safe_attribute
get :syntax_error
get :indent_error
get :unparsable
get :invalid_interpolation
get :filte... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/rails/config/initializers/secret_key_base.rb | Ruby | mit | 185 | master | 267 | # frozen_string_literal: true
version = [Rails::VERSION::MAJOR, Rails::VERSION::MINOR]
if version == [4, 0]
TestApp::Application.configure do
config.secret_key_base = YAML.load_file(Rails.root.join('config/secrets.yml'))[Rails.env]['secret_key_base']
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/rails/config/initializers/assets.rb | Ruby | mit | 185 | master | 516 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/rails/config/environments/production.rb | Ruby | mit | 185 | master | 3,334 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, al... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/rails/config/environments/development.rb | Ruby | mit | 185 | master | 1,630 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don'... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/rails/config/environments/test.rb | Ruby | mit | 185 | master | 1,788 | # frozen_string_literal: true
TestApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is ... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/rails/spec/requests/faml_spec.rb | Ruby | mit | 185 | master | 4,512 | # frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Faml with Rails', type: :request do
it 'renders views' do
get '/books/hello'
expect(response).to be_ok
expect(response).to render_template('books/hello')
expect(response).to render_template('layouts/application')
expect(response... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/helpers_spec.rb | Ruby | mit | 185 | master | 270 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Faml::Helpers, type: :render do
it 'has preserve method' do
expect(render_string('%span!= preserve "hello\nworld !"', extend_helpers: true)).to eq("<span>hello
world !</span>\n")
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/filters_spec.rb | Ruby | mit | 185 | master | 265 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'filter rendering', type: :render do
it 'raises error if unregistered filter name is given' do
expect { render_string(':eagletmt') }.to raise_error(Faml::FilterCompilers::NotFound)
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/multiline_spec.rb | Ruby | mit | 185 | master | 1,079 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Multiline rendering', type: :render do
it 'handles multiline syntax' do
expect(render_string(<<HAML)).to eq("<p>\nfoo bar baz\nquux\n</p>\n")
%p
= "foo " + |
"bar " + |
"baz" |
= "quux"
HAML
end
it 'handles mult... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/sanitize_spec.rb | Ruby | mit | 185 | master | 1,088 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Sanitize rendering', type: :render do
it 'parses sanitized script' do
# Default in faml
expect(render_string('&= "hello<p>unescape</p>world"')).to eq("hello<p>unescape</p>world\n")
expect(render_string(<<HAML)).to eq("<span>\... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/attribute_spec.rb | Ruby | mit | 185 | master | 6,572 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Attributes rendering', type: :render do
it 'parses attributes' do
expect(render_string('%span{class: "x"} hello')).to eq("<span class='x'>hello</span>\n")
end
it 'parses attributes' do
expect(render_string('%span{class: "x", "old" => 2}... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/hash_attribute_spec.rb | Ruby | mit | 185 | master | 2,708 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Hash attributes rendering', type: :render do
it 'renders nested attributes' do
expect(render_string('%span{foo: {bar: 1+2}} hello')).to eq("<span foo='{:bar=>3}'>hello</span>\n")
end
it 'renders code attributes' do
expect(render_stri... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/comment_spec.rb | Ruby | mit | 185 | master | 1,243 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Comment rendering', type: :render do
it 'renders html comment' do
expect(render_string('/ comments')).to eq("<!-- comments -->\n")
end
it 'strips spaces' do
expect(render_string('/ comments ')).to eq("<!-- comments -->\n")
end
... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/silent_script_spec.rb | Ruby | mit | 185 | master | 2,086 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'SilentScript rendering', type: :render do
it 'parses silent script' do
expect(render_string(<<HAML)).to eq("<span>0</span>\n<span>1</span>\n")
- 2.times do |i|
%span= i
HAML
end
it 'parses if' do
expect(render_string(<<HAML)).to eq("<... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/element_spec.rb | Ruby | mit | 185 | master | 2,414 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Element rendering', type: :render do
it 'parses one-line element' do
expect(render_string('%span hello')).to eq("<span>hello</span>\n")
end
it 'parses multi-line element' do
expect(render_string(<<HAML)).to eq("<span>\nhello\n</span>\n"... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/preserve_spec.rb | Ruby | mit | 185 | master | 361 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Preserve rendering', type: :render do
it 'parses preserved script' do
expect(render_string('~ "<p>hello\nworld</p>"')).to eq("<p>hello\nworld</p>\n")
expect(render_string('%span~ "<p>hello\nworld</p>"')).to eq("<span><p>hel... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/plain_spec.rb | Ruby | mit | 185 | master | 650 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Plain rendering', type: :render do
it 'outputs literally when prefixed with "\\"' do
expect(render_string('\= @title')).to eq("= @title\n")
end
it 'correctly escapes interpolation' do
expect(render_string(<<'HAML')).to eq("<span>foo\\3b... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/doctype_spec.rb | Ruby | mit | 185 | master | 2,562 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Doctype rendering', type: :render do
context 'with html format' do
it 'renders html5 doctype by default' do
expect(render_string('!!!')).to eq("<!DOCTYPE html>\n")
end
it 'renders xml doctype (silent)' do
expect(render_strin... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/newline_spec.rb | Ruby | mit | 185 | master | 2,102 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Newline with > and <', type: :render do
describe '>' do
it 'parses nuke-outer-whitespace (>)' do
expect(render_string(<<HAML)).to eq("<img><span>hello</span><img>\n")
%img
%span> hello
%img
HAML
expect(render_string(<<HAML)).to eq("... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/array_attribute_spec.rb | Ruby | mit | 185 | master | 2,875 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Array attributes rendering', type: :render do
describe 'class' do
it 'renders array class' do
with_each_attribute_type(:class, '"c1"', klass: 'c2') do |str|
expect(render_string(str)).to eq("<span class='c1 c2'></span>\n")
en... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/script_spec.rb | Ruby | mit | 185 | master | 1,239 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Script rendering', type: :render do
it 'parses script' do
expect(render_string('%span= 1 + 2')).to eq("<span>3</span>\n")
end
it 'parses multi-line script' do
expect(render_string(<<HAML)).to eq("<span>\n3\n</span>\n")
%span
= 1 + 2
H... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/unescape_spec.rb | Ruby | mit | 185 | master | 1,648 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Unescape rendering', type: :render do
it 'parses unescape script' do
expect(render_string('%span!= "hello<p>unescape</p>world"')).to eq("<span>hello<p>unescape</p>world</span>\n")
expect(render_string(<<HAML)).to eq("<span>\nhello<p>unescape... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/haml_comment_spec.rb | Ruby | mit | 185 | master | 477 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Haml comment rendering', type: :render do
it 'renders nothing' do
expect(render_string(<<HAML)).to eq("<div>\n<p>hello</p>\n<p>world</p>\n</div>\n")
%div
%p hello
-# this
should
not
be rendered
%p world
HAML
end
it 'pa... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/filters/preserve_spec.rb | Ruby | mit | 185 | master | 543 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Preserve filter rendering', type: :render do
it 'renders preserve filter' do
expect(render_string(<<'HAML')).to eq("<span>start</span>\nhello
 <p>wor
ld</p>
<span>hello</span>\n<span>end</span>\n")
%span start
:preserve
h... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/filters/ruby_spec.rb | Ruby | mit | 185 | master | 244 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Ruby filter rendering', type: :render do
it 'renders ruby filter' do
expect(render_string(<<HAML)).to eq("3\n")
:ruby
hash = {
a: 3,
}
= hash[:a]
HAML
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/filters/coffee_spec.rb | Ruby | mit | 185 | master | 650 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'CoffeeScript filter rendering', type: :render do
it 'renders CoffeeScript filter' do
html = render_string(<<HAML)
:coffee
square = (x) -> x * x
square(3)
HAML
expect(html).to include('<script>')
expect(html).to include('square = func... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/filters/plain_spec.rb | Ruby | mit | 185 | master | 488 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Plain filter rendering', type: :render do
it 'renders plain filter' do
expect(render_string(<<'HAML')).to eq("<span>\nhello\n<span>world</span>\n</span>\n")
%span
:plain
he#{'llo'}
%span world
HAML
end
it 'strips last empty lines' d... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/filters/css_spec.rb | Ruby | mit | 185 | master | 1,061 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'CSS filter rendering', type: :render do
it 'renders css filter' do
expect(render_string(<<HAML)).to eq("<div>\n<style>\n html { font-size: 12px; }\n</style>\n<span>hello</span>\n</div>\n")
%div
:css
html { font-size: 12px; }
%span hello... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/filters/scss_spec.rb | Ruby | mit | 185 | master | 657 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'SCSS filter rendering', type: :render do
it 'renders SCSS filter' do
html = render_string(<<'HAML')
:scss
nav {
ul {
margin: 0;
content: "hello";
}
}
HAML
expect(html).to include('<style>')
expect(html).to include... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/filters/cdata_spec.rb | Ruby | mit | 185 | master | 314 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'CDATA filter rendering', type: :render do
it 'renders CDATA filter' do
expect(render_string(<<'HAML')).to eq("<![CDATA[\n hello\n world\n <span>hello</span>\n]]>\n")
:cdata
hello
#{'world'}
<span>hello</span>
HAML
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/filters/sass_spec.rb | Ruby | mit | 185 | master | 626 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'SASS filter rendering', type: :render do
it 'renders SASS filter' do
html = render_string(<<'HAML')
:sass
nav
ul
margin: 0
content: "hello"
HAML
expect(html).to include('<style>')
expect(html).to include('nav ul {')
... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/filters/javascript_spec.rb | Ruby | mit | 185 | master | 1,048 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'JavaScript filter rendering', type: :render do
it 'renders javascript filter' do
expect(render_string(<<HAML)).to eq("<div>\n<script>\n alert('hello');\n</script>\n<span>world</span>\n</div>\n")
%div
:javascript
alert('hello');
%span wo... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/filters/markdown_spec.rb | Ruby | mit | 185 | master | 406 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Markdown filter rendering', type: :render do
it 'renders Markdown filter' do
expect(render_string(<<HAML)).to eq("<h1>hello</h1>\nworld\n")
:markdown
# hello
world
HAML
end
it 'parses string interpolation' do
expect(render_string(<<'H... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/render/filters/escaped_spec.rb | Ruby | mit | 185 | master | 397 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Escaped filter rendering', type: :render do
it ' renders escaped filter' do
expect(render_string(<<'HAML')).to eq("<span>start</span>\nhello\n <p>world</p>\n<span>hello</span>\n\n<span>end</span>\n")
%span start
:escaped... |
github | eagletmt/faml | https://github.com/eagletmt/faml | spec/support/incompatibilities_generator.rb | Ruby | mit | 185 | master | 4,630 | # frozen_string_literal: true
require 'pathname'
require 'singleton'
require 'hamlit/engine'
require 'hamlit/version'
class IncompatibilitiesGenerator
include Singleton
Record = Struct.new(:template, :options, :spec_path, :line_number, :caller_lineno, :faml_result, :haml_result, :hamlit_result) do
def incompa... |
github | eagletmt/faml | https://github.com/eagletmt/faml | benchmark/compiling.rb | Ruby | mit | 185 | master | 664 | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'benchmark/ips'
require 'haml'
require 'faml'
require 'hamlit'
require 'slim'
require 'escape_utils/html/haml'
unless ARGV[0]
$stderr.puts "Usage: #{$PROGRAM_NAME} template.haml [template.slim]"
exit 1
end
haml_code = File.read(ARGV[0])
slim_code = ARGV[1]... |
github | eagletmt/faml | https://github.com/eagletmt/faml | benchmark/context.rb | Ruby | mit | 185 | master | 263 | # frozen_string_literal: true
class Context
def header
'Colors'
end
def item
[{ name: 'red', current: true, url: '#red' },
{ name: 'green', current: false, url: '#green' },
{ name: 'blue', current: false, url: '#blue' }]
end
end |
github | eagletmt/faml | https://github.com/eagletmt/faml | benchmark/slim.rb | Ruby | mit | 185 | master | 943 | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'benchmark/ips'
require 'haml'
require 'faml'
require 'hamlit'
require 'slim'
require 'escape_utils/html/haml'
require_relative 'context'
haml_code = File.read(File.join(__dir__, 'view.haml'))
slim_code = File.read(File.join(__dir__, 'view.slim'))
context = C... |
github | eagletmt/faml | https://github.com/eagletmt/faml | benchmark/rendering.rb | Ruby | mit | 185 | master | 1,447 | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'benchmark/ips'
require 'haml'
require 'faml'
require 'hamlit'
require 'slim'
require 'escape_utils/html/haml'
unless ARGV[0]
$stderr.puts "Usage: #{$PROGRAM_NAME} template.haml [template.slim]"
exit 1
end
haml_code = File.read(ARGV[0])
slim_code = ARGV[1]... |
github | eagletmt/faml | https://github.com/eagletmt/faml | ext/attribute_builder/extconf.rb | Ruby | mit | 185 | master | 487 | # frozen_string_literal: true
require 'mkmf'
$CFLAGS << ' -Wall -W'
if $CXXFLAGS
# $CXXFLAGS might be undefined
# https://github.com/ruby/ruby/pull/492
$CXXFLAGS << ' -Wall -W'
end
houdini_dir = File.expand_path('../../vendor/houdini', __dir__)
$INCFLAGS << " -I#{houdini_dir}"
$srcs = %w[attribute_builder.cc]
%... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | flipflop.gemspec | Ruby | mit | 185 | master | 1,000 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "flipflop/version"
Gem::Specification.new do |s|
s.name = "flipflop"
s.version = Flipflop::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Paul Annesley", "Rolf Timmermans", "Jippe Holwerda"]
s.email ... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | Rakefile | Ruby | mit | 185 | master | 1,321 | require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new("test" => "assets:compile") do |test|
test.pattern = "test/**/*_test.rb"
end
Rake::TestTask.new("test:unit" => "assets:compile") do |test|
test.pattern = "test/unit/**/*_test.rb"
end
Rake::TestTask.new("test:integration" => "assets:compile") ... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | Gemfile | Ruby | mit | 185 | master | 1,018 | source "https://rubygems.org"
gemspec
group :test do
version = ENV["RAILS_VERSION"] || "master"
if version == "master"
gem "rails", github: "rails/rails"
gem "arel", github: "rails/arel"
else
gem "rails", "~> #{version}.0"
end
gem "bootstrap", "= 4.0.0.alpha6", require: false
gem "fakeredis",... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | app/controllers/flipflop/strategies_controller.rb | Ruby | mit | 185 | master | 914 | module Flipflop
class StrategiesController < ApplicationController
include ActionController::RequestForgeryProtection
def update
FeatureSet.current.switch!(feature_key, strategy_key, enable?)
redirect_to features_url(anchor: "#{feature_key}-#{strategy_key}".parameterize)
end
def destroy
... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | app/controllers/flipflop/features_controller.rb | Ruby | mit | 185 | master | 1,893 | module Flipflop
class FeaturesController < ApplicationController
include ActionController::RequestForgeryProtection
include ActionController::Rendering
include ActionView::Rendering
include ActionView::Layouts
# Allows overriding layout by inheriting from this controller.
layout "flipflop"
... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/test_helper.rb | Ruby | mit | 185 | master | 6,199 | require "bundler/setup"
require "flipflop"
gem "minitest"
require "minitest/autorun"
require "action_controller"
require "rails/generators"
# Who is setting this to true? :o
$VERBOSE = false
def create_request
env = Rack::MockRequest.env_for("/example")
request = ActionDispatch::TestRequest.new(env)
request.h... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/integration/app_test.rb | Ruby | mit | 185 | master | 2,020 | require File.expand_path("../../test_helper", __FILE__)
describe Flipflop do
describe "without engine" do
before do
@app = TestApp.new
end
after do
@app.unload!
end
subject do
@app
end
describe "configuration" do
it "should be added to dev" do
assert_mat... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/integration/dashboard_test.rb | Ruby | mit | 185 | master | 17,082 | require File.expand_path("../../test_helper", __FILE__)
require "capybara/dsl"
describe Flipflop do
include Capybara::DSL
describe "without translations" do
before do
@app = TestApp.new
end
after do
@app.unload!
end
subject do
@app
end
describe "without features" ... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/feature_set_test.rb | Ruby | mit | 185 | master | 4,386 | require File.expand_path("../../test_helper", __FILE__)
class NullStrategy < Flipflop::Strategies::AbstractStrategy
def enabled?(feature)
end
end
class TrueStrategy < Flipflop::Strategies::AbstractStrategy
def enabled?(feature)
true
end
end
class FalseStrategy < Flipflop::Strategies::AbstractStrategy
d... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/feature_definition_test.rb | Ruby | mit | 185 | master | 2,309 | require File.expand_path("../../test_helper", __FILE__)
describe Flipflop::FeatureDefinition do
describe "with defaults" do
subject do
Flipflop::FeatureDefinition.new(:my_key)
end
it "should have specified key" do
assert_equal :my_key, subject.key
end
it "should have name derived fr... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/flipflop_test.rb | Ruby | mit | 185 | master | 2,577 | require File.expand_path("../../test_helper", __FILE__)
describe Flipflop do
before do
Flipflop::FeatureSet.current.replace do
Flipflop.configure do
feature :one, default: true
feature :two, default: false
end
end
end
describe "replace" do
before do
Flipflop::Featur... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/feature_cache_test.rb | Ruby | mit | 185 | master | 3,419 | require File.expand_path("../../test_helper", __FILE__)
describe Flipflop::FeatureCache do
subject do
Flipflop::FeatureCache.current
end
after do
Flipflop::FeatureCache.current.disable!
end
describe "current" do
it "should return same instance" do
current = subject
assert_equal curr... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/configurable_test.rb | Ruby | mit | 185 | master | 3,828 | require File.expand_path("../../test_helper", __FILE__)
class FailingStrategy < Flipflop::Strategies::AbstractStrategy
def initialize(*)
raise "Oops"
end
end
describe Flipflop::Configurable do
subject do
Flipflop::FeatureSet.current.send(:initialize)
Module.new do
extend Flipflop::Configurabl... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/group_definition_test.rb | Ruby | mit | 185 | master | 486 | require File.expand_path("../../test_helper", __FILE__)
describe Flipflop::GroupDefinition do
describe "with defaults" do
subject do
Flipflop::GroupDefinition.new(:my_key)
end
it "should have specified key" do
assert_equal :my_key, subject.key
end
it "should have name derived from k... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies_controller_test.rb | Ruby | mit | 185 | master | 961 | require File.expand_path("../../test_helper", __FILE__)
describe "Flipflop::StrategiesController" do
before do
@app = TestApp.new
end
after do
@app.unload!
end
subject do
Flipflop::StrategiesController.new
end
describe "enable?" do
it "should return false when commit is empty" do
... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/tasks/support/methods_test.rb | Ruby | mit | 185 | master | 2,246 | require File.expand_path('../../../../test_helper', __FILE__)
require File.expand_path('../../../../../lib/tasks/support/methods', __FILE__)
describe Flipflop::Rake::SupportMethods do
subject do
object = Object.new
object.extend Flipflop::Rake::SupportMethods
end
describe '#status_label' do
it 'retu... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies/abstract_strategy_request_test.rb | Ruby | mit | 185 | master | 1,235 | require File.expand_path("../../../test_helper", __FILE__)
describe Flipflop::Strategies::AbstractStrategy::RequestInterceptor do
subject do
Class.new(ActionController::Metal) do
class << self
attr_accessor :request
end
include AbstractController::Callbacks
include Flipflop::Stra... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies/abstract_strategy_test.rb | Ruby | mit | 185 | master | 3,319 | require File.expand_path("../../../test_helper", __FILE__)
describe Flipflop::Strategies::AbstractStrategy do
after do
Flipflop::Strategies::AbstractStrategy::RequestInterceptor.request = nil
end
describe "with defaults" do
subject do
Flipflop::Strategies::AbstractStrategy.new.freeze
end
... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies/active_record_strategy_test.rb | Ruby | mit | 185 | master | 6,263 | require File.expand_path("../../../test_helper", __FILE__)
class ResultSet
attr_reader :results
def initialize(key, results = [])
@key, @results = key, results
end
def first_or_initialize
@results.first or MyAr::Feature.new(@key, false)
end
def first
@results.first
end
end
module MyAr
c... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies/options_hasher_test.rb | Ruby | mit | 185 | master | 1,813 | require File.expand_path("../../../test_helper", __FILE__)
class Test
def initialize(value)
@value = value
end
end
class Test2
def initialize(value)
@value = value
end
end
describe Flipflop::Strategies::OptionsHasher do
subject do
Flipflop::Strategies::OptionsHasher
end
def hash(value)
... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies/cookie_strategy_test.rb | Ruby | mit | 185 | master | 3,706 | require File.expand_path("../../../test_helper", __FILE__)
describe Flipflop::Strategies::CookieStrategy do
subject do
Flipflop::Strategies::CookieStrategy.new.freeze
end
describe "in request context" do
before do
Flipflop::Strategies::AbstractStrategy::RequestInterceptor.request = create_request
... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies/test_strategy_test.rb | Ruby | mit | 185 | master | 1,948 | require File.expand_path("../../../test_helper", __FILE__)
describe Flipflop::Strategies::TestStrategy do
describe "with defaults" do
subject do
Flipflop::Strategies::TestStrategy.new.freeze
end
it "should have default name" do
assert_equal "test", subject.name
end
it "should have t... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies/sequel_strategy_test.rb | Ruby | mit | 185 | master | 6,276 | require File.expand_path("../../../test_helper", __FILE__)
class ResultSet
attr_reader :results
def initialize(key, results = [])
@key, @results = key, results
end
def first
@results.first
end
end
module MySq
class Feature < Struct.new(:key, :enabled)
class << self
attr_accessor :resul... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies/session_strategy_test.rb | Ruby | mit | 185 | master | 3,032 | require File.expand_path("../../../test_helper", __FILE__)
describe Flipflop::Strategies::SessionStrategy do
subject do
Flipflop::Strategies::SessionStrategy.new.freeze
end
describe "in request context" do
before do
Flipflop::Strategies::AbstractStrategy::RequestInterceptor.request = create_reques... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies/query_string_strategy_test.rb | Ruby | mit | 185 | master | 2,177 | require File.expand_path("../../../test_helper", __FILE__)
describe Flipflop::Strategies::QueryStringStrategy do
subject do
Flipflop::Strategies::QueryStringStrategy.new.freeze
end
describe "in request context" do
before do
Flipflop::Strategies::AbstractStrategy::RequestInterceptor.request = creat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.