question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inject sub-components from context

See original GitHub issue

Hi,

Thanks so much for your work on Fractal.

I am the maintainer of the Drupal integration of Fractal: https://www.drupal.org/project/ui_patterns_fractal

According to the Fractal documentation, we need to set the sub-components inside the template file:

<div class="searchbox">
    <input type="search" name="keywords">
    {{> @button }}
</div>

https://fractal.build/guide/components/sub-components

It would be very useful to be able to keep those templates “sub-components agnostic”, by specifying a simple variable:

<div class="searchbox">
    <input type="search" name="keywords">
    {{ submit }}
</div>

And inject the sub-component from the description file context. For example:

title: Search Box
context:
  submit: @button

Other proposal, with context overriding:

title: Search Box
context:
  submit: 
    render: @button
    text: Go!

For Drupal integration, it is a must-have, because its render system works like that: https://www.drupal.org/docs/8/api/render-api/render-arrays

And I strongly believe this mechanism would be useful even for non-Drupal people.

Is it already possible with Fractal?

PS: I am using the Twig engine by the way: https://github.com/frctl/twig

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

0reactions
mihkeleidastcommented, May 2, 2020

This has been recently implemented in #573

Read more comments on GitHub >

github_iconTop Results From Across the Web

one object if injected into 2 subcomponents under same ...
inject (this) in onCreate creates a new instance of that subcomponent and uses it to inject the Activity instance. Your @CustomScope (which may ......
Read more >
Using Dagger2 SubComponents to Propagate Dependancies
In this post I am going to demonstrate use of Subcomponents in a very common android app use-case and show how dependency Injection...
Read more >
Dagger & Android Thoughts: Dependency Injection in Android
1. What is AndroidInjection.inject doing? · 2. How does it know which Subcomponent Builder to use? · 3. Inject the Builder to the...
Read more >
Dagger Scopes, Subcomponents, Memory, and… Who Cares
Dagger subcomponent used to provide dependencies specific to the Farewell screens. For this experiment, the app component is still initialized ...
Read more >
Using Dagger in Android apps
To inject an object in the activity, you'd use the appComponent defined in your Application class and call the inject() method, passing in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found