Can I render all partials and their contents on a page with assemble? - assemble

I have a bunch of partials in the following directory structure:
src
└── content
├── pages
│ ├── index.hbs
│ └── patterns.hbs
├── partials
│ ├── _footer-subpage.hbs
│ ├── _footer.hbs
│ ├── _head-subpage.hbs
│ ├── _head.hbs
│ └── patterns
│ └── dropdown
│ ├── dropdown.hbs
│ └── dropdown.json
└── templates
├── custom.hbs
└── default.hbs
and I want to be able to loop over all partials within src/content/partials/patterns directory and output their contents on a page. A the moment I am manually including the partials like so:
{{> dropdown }}
{{> another-partial }}
{{> another-partial }}
...
Is it possible to do this dynamically like you can with pages collections?
Edit:
Sorry, I should have been more detailed in what I'm trying to achieve. It's a bit more complex...
This is what I am currently doing in full detail but would like to do programmatically:
<h3>{{dropdown.info.title}}</h3> <-- name
<p>{{dropdown.info.description}}</p> <-- description
{{> dropdown dropdown }}
{{#markdown}}``\{{> dropdown dropdown }}``{{/markdown}} <-- example
<h4>dropdown.hbs</h4>
{{#markdown}}
{{embed 'src/content/partials/patterns/dropdown/dropdown.hbs' 'html'}} <-- source
{{/markdown}}
<h4>dropdown.json</h4>
{{#markdown}}
{{embed 'src/content/partials/patterns/dropdown/dropdown.json' 'json'}} <-- data
{{/markdown}}
The dropdown.info.title is using the .json file within the same directory as the partial for data.
I'm basically replicating functionality from pattern-lab.info to pull in a bunch of components to create a library of "patterns" but don't want to do it manually.
Here's an example of the desired output.
The code I'm using is here https://github.com/sheedy/ux-prototype (the "dev" branch).

Try using the compose helper
You could then do...
{{compose src="src/content/partials/patterns/**/*.hbs"}}
{{#content}}
{{/compose}}

Related

Kubernetes Kustomize patching - Can't patch a file located in base

I have a huge patch file that I want to apply to specific overlays. I usually patch files under overlays as it is supposed to be. But the file is same and I do not want to copy it to each overlay. If I could keep my patch file app-new-manifest.yaml under base and patch it under overlay with a single line in kustomization.yaml, it would be awesome.
├── base
│ ├── app-new-manifest.yaml # I am trying to patch this
│ ├── kustomization.yaml
│ ├── app
│ │ ├── app.yaml
│ │ └── kustomization.yaml
└── overlay
└── environment1
│ ├── kustomization.yaml # I want to patch app-new-manifest.yaml in base
│
└── environment2
│ ├── kustomization.yaml # No patch. app.yaml will be as is
│
└── environment3
├── kustomization.yaml # I want to patch app-new-manifest.yaml in base
When I'm trying to do so, I get this error:
'/base/app/app-new-manifest.yaml' is not in or below '/overlays/environment1'
Which means, when you patch, the patch file has to be located under overlay not base. Is there any workaround to do this? Because copying the same file to each environment does not make sense to me.
Any ideas around this will highly be appreciated, thanks!
Edit:
Add /base/app/kustomization.yaml
resources:
- app.yaml
Add /overlays/environment1/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base/app
patchesStrategicMerge:
- ../../base/app/app-new-manifest.yaml # Patch new manifest
kustomize version:
{Version:kustomize/v4.2.0 GitCommit:d53a2ad45d04b0264bcee9e19879437d851cb778 BuildDate:2021-07-01T00:44:28+01:00 GoOs:darwin GoArch:amd64}
You can't include a file that is outside of you current directory, but you can include another directory that has a kustomize.yaml file. So organize your layout like this:
.
├── base
└── overlay
├── patched_based
├── environment1
├── environment2
└── environment3
In overlay/patched_base, place your patch file and a kustomization file like:
resources:
- ../base
patchesStrategicMerge:
- app-new-manifest.yaml
In overlay/environment1 and overlay/environment3, you have:
resources:
- ../patched_base
Whereas in overlay/environment2, you have:
resources:
- ../../base
I think this solves all your requirements:
You only need a single instance of the patch
You can choose to use the patch or not from each individual overlay

How to use my own common files in keycloak theme?

I would like to use common resources in my keycloak theme but import feature is for extand existing theme but how to use common in my theme ?
I would like to import my own common files but according to the documentation the import only allows to use the common files of another theme but how to use it without extending on another theme ?
My structure
.
├── META-INF/
│ └── keycloak-themes.json
└── theme/
└── my-custom-theme/
├── account/
│ ├── *.ftl
│ └── theme.properties
├── common/
│ └── resources/
│ └── css/
│ └── bootstrap.min.css
└── login
In my theme.properties (login)
locales=en,fr
styles=css/login.css
# which I already tried
# -> by default keycloak use common/keycloak (but how to change to my own common resources ? I tried this import=common/my-custom-theme but I have an error 500)
stylesCommon=css/bootstrap.min.css (it's bootstrap file of keycloak (3.4.1 :/)
Anyone have an idea ?
I solved it by adding the following to my theme.properties:
import=common/my-custom-theme
styles=css/bootstrap.min.css
# stylesCommon=css/bootstrap.min.css <-- not working
Tested it with Keycloak server version 15.0.2
To include in 'stylesCommon', please check if you have following in template.ftl
<#if properties.stylesCommon?has_content>
<#list properties.stylesCommon?split(' ') as style>
<link href="${url.resourcesCommonPath}/${style}" rel="stylesheet" />
</#list>
</#if>

Links to json files

my directory structure is
├── xxx
│   ├── 01.md
| └── 02.md
├── auth
│   ├── j1.json
│   ├── j2.json
│   └── j3.json
└── default.template.html
And I link jsons from markdowns like Auth. It makes sense as we use there files as test scenarios and in json files we have credentials and roles. But if I try to generate html it fails on unresolved internal reference: ../auth/aspect_admin.json. I tried to exclude the link checking but without any help. The best would be to leave it as a link in md file but somehow follow the link and include the json as code block in generated html. Is it possible?
It was a bug and will be fixed in next version https://github.com/planet42/Laika/issues/148

importing style-sheet into app.scss to use throughout project

I want to use a style page across my app.
in the app.scss file I tried using:
#import "../global-scss/html-table-styles.scss";
this does not work.
Pasting the style directly into the app.scss file does work but I would rather not do that.
Is what I'm trying to accomplish possible and if so, what am I doing wrong?
If your file structure is like this:
├── src
│   ├── app
│   │   ├── app.component.ts
│   │   ├── app.module.ts
│   │   ├── app.scss
│   │   └── main.ts
// ... pages, components ...
| └── theme
│   ├── custom-styles.scss
...the import line should be:
#import "../theme/custom-styles.scss";
The problem was due to my poor understanding of style-sheets and because there is an answer already so I am unable to delete.
In the style-sheet I was trying to import I had followed the pattern used for styles local to a page and had a base style tag
eg:
html-table-styles{
//my styles
}
when i imported #import "../global-scss/html-table-styles.scss"; the styles were not being used, removing html-table-styles solved my issue

unresolved import for module imports in Visuial Studio Code

I have opened a folder in VS code and I am trying to set it up.
It's a python project and its directory structure is as:
Project
├── common_features
│ ├── ...
├── core
│ ├── features
│ └── main.py
│ └── tests
├── django project
│ ├── django_app1
│ ├── manage.py
│ ├── ...
└── tests
│ ├── ...
└── runner.py
The project runs as a django project from the django_project dir. It uses modules located in common_features and core. Core is designed such that it could also run on its own. You can also run core from runner.py
The problem is that all our module imports are not being resolved but 3rd party packages work well.
unresolved import 'core.config' Python(unresolved-import)
In PyCharm, I have marked Project, core and django_project as "sources root" and it works like a charm. Not sure how to do that in VS code.
I have tried making some changes in launch.json and settings.json but none are working. I am new to VS code so I'm unable to understand what it is that I'm doing wrong.
Thanks.
Can you try adding the following line to your settings.json file?
{
"python.autoComplete.extraPaths": ["./src"]
}
More info about this here: https://github.com/microsoft/python-language-server/blob/master/TROUBLESHOOTING.md#unresolved-import-warnings