Shopify / Shopify/liquid

Generalize tag render_partial

Open
#995 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
11.9k
Forks
1.5k
Avg merge
17h 55m
Merged PRs (30d)
3

Description

I have a tag which I call:

{% render_partial 'my_partial' %}

This is the tag:

class RenderPartial < Liquid::Tag
  def initialize(tag_name, partial_name, options)
    super
    @partial_name = partial_name.gsub(/\s|"|'/, "").strip
  end

  def render(context)
    context.registers[:controller].dup.render(partial: @partial_name)
  end
end

Liquid::Template.register_tag("render_partial", RenderPartial)

I want to generalize this tag for when I have to pass parameters to the partial. On rails would be:

<%= render("user/subscriptions/subscribable_box",
        subscribable: current_site,
        title: t("subscribable_box.title")) %>

Has anyone solved this kind of partial rendering? Thanks!!!!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the custom RenderPartial tag and the Liquid::Tag API shown in the issue. Clarify the parameter syntax and how values should reach the Rails partial, then identify the project entry points and tests needed to define supported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.