k0kubun / hamlit

High Performance Haml Implementation
https://rubygems.org/gems/hamlit
Other
981 stars 59 forks source link

old haml dependency #77

Closed mibamur closed 8 years ago

mibamur commented 8 years ago

Hello again! There are some gem like gem 'opal-rails' which depend on HAML::Filters

worked only with require: false

# Gemfile

# gem 'haml'
gem 'haml-rails', require: false
gem 'hamlit', github: 'k0kubun/hamlit', submodules: true
gem 'hamlit-rails', github: 'mfung/hamlit-rails'

May you can tell me best solution how fix it.

Or how better rewrite Class and method for back compability?

mibamur commented 8 years ago

example

Other gem call often some thing like this

https://github.com/opal/opal-rails/blob/master/lib/opal/rails/haml_filter.rb#L1

module Haml::Filters::Opal
  include Haml::Filters::Base
...
k0kubun commented 8 years ago

Filters implemented with Haml::Filters::Base can't be used for Hamlit. You should re-implement it with Hamlit::Filters::Base.

I think we should create Hamlit::Filters::Opal in opal-rails/lib/opal/rails/hamlit_filter.rb. Since Hamlit's backend is the same as Slim, it'll be similar to Slim::Embedded::OpalEngine.

mibamur commented 8 years ago

Ok - try it now. Thanks

Here is another re-implement solution

Did you see it? faster_path https://github.com/danielpclark/faster_path/blob/master/lib/faster_path/optional/monkeypatches.rb

I want something like this monkeypatches

k0kubun commented 8 years ago

Monkey-patching is basically a bad idea. It makes hard to find where the method is defined. In addition, monkey-patching implementation is fragile since it's separately maintained in spite of tight coupling. Thus I'm reluctant to replace Haml's constant or methods in Hamlit.

Because Hamlit's goal is to be a replacement of Haml and haml.gem itself does not contain the filter for Opal, I don't accept adding Opal filter to hamlit.gem. So closing this issue.

k0kubun commented 8 years ago

I suggest two ways to solve this issue.

k0kubun commented 8 years ago

Creating something like hamlit-opal or opal-hamlit

Here it is https://github.com/hamlit/hamlit-opal. It's available as hamlit-opal v0.0.1.beta1. It's just conceptual and never tested.

mibamur commented 8 years ago

great