Dynamically including javascript files - assemble

I was wondering what an intuitive way is to include js files in the template. The js files are located at src/js and the template is at src/template/default.hbs and the index file at src/index.hbs. Is there a way that I could iterate over src/js/**/*.js to display them from src/template/default.hbs?

Related

TYPO3: Where can I find the template created in the backend?

I'm trying to create separate templates for webpages with either a single or a double column structure. Currently my webpage only has one template, placed on the root page which is used by all its subpages.
However, I cannot find the template in myextension/Resources/Private/Templates as this folder is empty. Where is the template located in my extension and where should I add the alternative template?
I assume you use "fluid_styled_template"? Then the templates are in that respective core directory, in "Resources/Private".
If you want to manipulate them, copy them to your sitePackage into "Resources/Private/Extension/fluid_styled_content" (that at least is one of the recommended ways where to place it) and override the TypoScript that "fluid_stlyed_content" provides.
templateis not unique in TYPO3 context. we have:
typoscript records, maybe also as files which are included in a record or by PHP
HTML files, which are define a markup for parts of the website
they can be differed in
Marker-Templated. The old and less and less used kind with markers and subparts as placeholders for data defined in typoscript
Fluid templates. The modern kind with control structures and data objects
with the statemant
my webpage only has one template, placed on the root page
it is not clear what you mean:
records are defined in pages -> typoscript templates
maybe you mean in the root page a template is selected. that could mean HTML templates, probably fluid templates as the path myextension/Resources/Private/Templates matches the usual structure for fluid templates.
assuming fluid templates:
Templates are search in a list of folders. This list is managed in typoscript.
Any usage has it's own list and the list of your main/page template probably is at page.10.templatePaths. You can look for it in the TSOB (Typoscript Object browser)
If the list consists of one entry only you have only the basic config.
As the list of folders is consulted each time a template (,partial, layout) is accessed and only that file with matching name in the folder with highest priority is taken you can add your folders with higher numbers in the list so you do not need to change the original files (use copies in your folder to modify) or add files to the original folder (inside of other extensions).
So you need two things:
create your template file in an appropriate folder
(ext:myextension/Resources/Private/Templates sounds good)
and add this folder to the list of folders for these templates
(e.g. page.10.templatePaths.20 = EXT:myextension/Resources/Private/Templates)

Merge JS files into one Adobe AEM

I have the following code to pull in two different categories but this outputs 6 separate files and I would like the output to be just one. How can this be done in AEM 6.0?
<clientlib data-sly-call="${clientLib.js # categories=['cq.foundation-main','cq.shared']}" data-sly-unwrap />
Thanks
In AEM, a category include will merge and compress all the files into a single js (or css) include. This is done per category include.
If you want to merge multiple categories, you should consider using the embed option in categories dependencies. How this works is:
Create a new category (for e.g. cq-embed)
Define embed dependencies ('cq.foundation-main','cq.shared') for the new category you have created.
Reference your new category.
You can also use this tool from ACS to optimise the includes:
https://adobe-consulting-services.github.io/acs-aem-tools/features/clientlibs-optimizer/index.html
It allows you to create the embed categories and reference them in a much cleaner way.

How to create pathfield generically so that it handles all extensions in cq5

When we take a pathfield value in jsp, need to provide harcoded ".html" or ".pdf".
Is there any way to make pathfield generic, hence no need to provide hard coded extensions? So if a user selects .pdf it will display a pdf file and if user selects .html it will open a html file.
Not sure if there is a OOB way to do this. Alternatively, You can create a script/custom jstl tag which take path as input, load resource and find out resource type and generate path with correct extn as output.
Call this script from all your components which generate links.
Another option is you extend com.day.cq.rewriter.pipeline.RequestRewriter and in rewriteLink() function write your logic to set correct extn.

Matching of data files to pages

I have used the assemble/boilerplate-site as a test bed. Following the examples on http://assemble.io/docs/Data.html I have created a page named test.hbs and a data file named test.yml.
The yaml file contains:
title: stuff
when running grunt assemble, a test.html page is assembled into the destination directory. if my test.hbs contains the tag {{title}} the title is not added from the data file, however a tag of {{test.title}} does add the title from the data file.
on the docs page http://assemble.io/docs/options-data.html it states:
When using "external" data files (versus YAML front matter), if name of the data file is the same as the associated template then Assemble will automatically associate the two files.
I also need to use the {{title}} tag in my layout. This works if I use YFM at the top of the page rather than an external data file.
Am I misunderstanding how external data files are associated with a page or am I missing something?
You can use {{page.title}} in your test.hbs and layout.hbs files to access the variable without having to specify the actual page name.

Purpose for Word Open XML and content controls binding

For word report generation, I am looking at binding XML to content controls to see if it is any easier than to use Word Interop and hardcode index reference to content controls to assign values to them.
However, I don't really understand how to do it.
My work flow is entering information in Excel and then generate an XML file to have content controls populated by XML, however, what I read is the other way round: Word Control Control Toolkit and descriptions where the XML is populated by user entering information in Word, and then programmer to unzip docx file to retrieve the XML file.
How can I populate content controls with XML?
There are samples on generating Word documents from Word templates, XML and data bound content controls # http://worddocgenerator.codeplex.com/
Set up the mapped content controls in the 'template' docx using the content control toolkit or similar. Do this using a sample XML file containing your Excel data.
Now you have that template document, at run time you can inject your XML file into it (ie replace the custom xml part it contains, with your instance data), in C# or Java or whatever.
When the user opens the document in Word 2007/2010, the information in the custom XML part will automatically be copied into the bound controls, and visible to the user.
Note that content control data binding doesn't easily support repeating data (eg populating table rows) in Word 2007/2010, though there are ways to do it.