Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support capture and content_for with Hamlit #1580

Merged
merged 2 commits into from
Dec 30, 2019

Conversation

k0kubun
Copy link
Contributor

@k0kubun k0kubun commented Nov 29, 2019

Problem

As explained in k0kubun/hamlit#150, sinatra-contrib's capture and yield_content don't work with hamlit.gem (another implementation of Haml) because they use helpers specific to haml.gem.

Solution

Let them stop using haml.gem-specific helpers if :haml engine is not Tilt::HamlTemplate (but Hamlit::Block::Template).
Note that hamlit-block plugin is necessary to make sinatra-contrib's capture work with Hamlit.

gem 'liquid', '~> 2.6.x'
gem 'slim'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slim 2.1.0 is super old and relies on temple ~> 0.6.9. Because hamlit relies on newer temple, I wanted to unpin the slim version. (Since the line is modified, I also moved the line so that they're ordered alphabetically)

def haml?
@current_engine == :haml
@current_engine == :haml && Tilt[:haml] == Tilt::HamlTemplate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this extra check necessary?

Copy link
Contributor Author

@k0kubun k0kubun Dec 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tilt[:haml] can also be Hamlit::Template so that it can be used for .haml files, and haml? is currently used for branches really specific for haml.gem like Haml helper usages (which Hamlit basically doesn't support), not Haml language's syntax.

Should we have the Tilt[:haml] == Tilt::HamlTemplate check outside haml? for each branches, or should we rename it to haml_gem??

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I understand now. I feel like this could be confusing since hamlit really is a haml engine. How many branches are there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are just two actually. Does this make more sense to you then? 58e1be0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I do like that better. Hopefully that helps us see areas to investigate refactoring.

@namusyaka namusyaka self-assigned this Dec 30, 2019
@namusyaka namusyaka self-requested a review December 30, 2019 03:54
Copy link
Member

@namusyaka namusyaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@namusyaka namusyaka merged commit 7c144ee into sinatra:master Dec 30, 2019
@k0kubun k0kubun deleted the hamlit-support branch December 30, 2019 04:42
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Mar 20, 2020
Update ruby-sinatra to 2.0.8.1.


## 2.0.8.1 / 2020-01-02

* Allow multiple hashes to be passed in `merge` and `merge!` for `Sinatra::IndifferentHash` [#1572](sinatra/sinatra#1572) by Shota Iguchi

## 2.0.8 / 2020-01-01

* Lookup Tilt class for template engine without loading files [#1558](sinatra/sinatra#1558). Fixes [#1172](sinatra/sinatra#1172) by Jordan Owens

* Add request info in NotFound exception [#1566](sinatra/sinatra#1566) by Stefan Sundin

* Add `.yaml` support in `Sinatra::Contrib::ConfigFile` [#1564](sinatra/sinatra#1564). Fixes [#1563](sinatra/sinatra#1563) by Emerson Manabu Araki

* Remove only routing parameters from @params hash [#1569](sinatra/sinatra#1569). Fixes [#1567](sinatra/sinatra#1567) by Jordan Owens, Horacio

* Support `capture` and `content_for` with Hamlit [#1580](sinatra/sinatra#1580) by Takashi Kokubun

* Eliminate warnings of keyword parameter for Ruby 2.7.0 [#1581](sinatra/sinatra#1581) by Osamtimizer

## 2.0.7 / 2019-08-22

* Fix a regression [#1560](sinatra/sinatra#1560) by Kunpei Sakai

## 2.0.6 / 2019-08-21

* Fix an issue setting environment from command line option [#1547](sinatra/sinatra#1547), [#1554](sinatra/sinatra#1554) by Jordan Owens, Kunpei Sakai

* Support pandoc as a new markdown renderer [#1533](sinatra/sinatra#1533) by Vasiliy

* Remove outdated code for tilt 1.x [#1532](sinatra/sinatra#1532) by Vasiliy

* Remove an extra logic for `force_encoding` [#1527](sinatra/sinatra#1527) by Jordan Owens

* Avoid multiple errors even if `params` contains special values [#1526](sinatra/sinatra#1527) by Kunpei Sakai

* Support `bundler/inline` with `require 'sinatra'` integration [#1520](sinatra/sinatra#1520) by Kunpei Sakai

* Avoid `TypeError` when params contain a key without a value on Ruby < 2.4 [#1516](sinatra/sinatra#1516) by Samuel Giddins

* Improve development support and documentation and source code by  Olle Jonsson, Basavanagowda Kanur, Yuki MINAMIYA
@k0kubun k0kubun mentioned this pull request Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants