How use a defined PPT template on PPTXGEN - pptxgenjs

I have a defined template, and I want to use it on the ppt exported using PPTXGEN LIBRARY.
is it possible ?

Only if you convert your template to (i.e. implement your template in) Javascript.
I found a python package here: python-pptx-text-replacer
If you are in an company, there's a commercial package called docxtemplate.

Related

Using handlebars to filter specific products from a JSON object?

Kind of a weird and specific question but here I go.
I can currently pull all my products through YAML and through some really brute-force methods, I would be able to sort the product out by custom fields.
I have a multiple choice wizard the user has to fill and in the end, I get an object that looks something like this:
{
stoneType: ['Granite', 'Quartz', 'Glass'],
stoneFinish: ['Polished', 'Honed'],
stoneConcern: ['Floor Care'],
labels: ['Daily Cleaning', 'Stain Removal']
}
I can't (or at least I don't know how) to get this data into my HTML to use the data stored in my YAML code and render the specific products.
I believe I can solve this issue if I were able to pass the array of products into javascript using some sort of handlebars helper(?) but Bigcommerce doesn't allow for custom helper functions.
I read online that you can bypass this by installing handlebars but that is not working for me.
When I installed handlebars through NPM, I get this error:
GET http://localhost:3000/stencil/00000000-0000-0000-0000-000000000001/dist/theme-bundle.main.js 404 (Not Found)
Is there a way for me to get custom helper functions working or another possible idea to sort & filter the products?
Thank you, appreciate the help.
EDIT: I have also tried manually downloading Handlebars.js including the file but I get the error Handlebars is not defined. I must be doing something wrong...

How to add correctly use Meteor package in a angular2-meteor project?

I am writing an angular2-meteor program.
When I am using urigo:angular2-meteor package, I add reference path like this:
/// <reference path="../typings/angular2-meteor.d.ts" />
The question is: can I use other normal meteor packages in a angular2-meteor project? Or I can only use some packages written for angular2-meteor specifically.
For example, if I want to use yuukan:streamy, how can I use it correctly? Right now, I have one line code
Streamy.broadcast('hello', {data: 'world!'});
When I compile it, it shows: Cannot find name 'Streamy'.
Thanks!
you can use all the libraries from meteor.
you will have 2 choices.
find the streamy definition file (streamy.d.ts) if it exists. This will give you autocompletion and compile errors if you misuse streamy functions.
If you dont find a definition file than just add declare var Streamy at the top of the file you want to use it. The library is already there if you add it via atmosphere. But typescript does not know about it. By declaring the variable you tell typescript that this exists and it wont complain when compiling.

"Packages cannot be nested" error in Flex

I want to use SoundFacade class from Adobe. (Here, from github). I simple created an "ActionScript File" and paste all the code. But when I want to compile my app I got following error:
1037: Packages cannot be nested.
The only reason I can guess is that the package must somehow put into the project or something.
EDIT:
Even when I just put a simple empty package I got the error:
package {
}
How to Reproduce the bug?
Create a new Flex Mobile Project.
Click New > ActionScript File
type package { }
include new package in one your views
code:
<fx:Script source="../SoundFacade.as" />
You will get the error
I find the solution. I was actually unaware of the package naming rule. Here is the answer to this problem: http://forums.adobe.com/message/4299377
The tag will insert your
SoundFacade.as file into the MXML file (similar to an include in
C/C++). That will cause an invalid syntax.
Give your package a name (in this case it should be called SoundFacade
because that is the name of the folder it is in) then use the import
statement inside your script tag. Make sure you adhere to the
recommended file, namespace, package and class naming structure.
That's usually a reverse-DNS style: com.adobe.utils.bla.bla.bla.
If package name is blank and the source is in the default folder, you
don't need to import it.

Write Tridion dreamweaver identifier as output package

While working on compound page templating project I have discovered very interesting issue. Customer uses ${stringvalue-session-or-something-specific} in their custom developed applications that are saved and rendered in component templates using XSLT. When try to render the component presentations containing reserved Tridion dreamweaver identifier (${}) I have got Template Builder error similar to
JScriptException: Expression '""["scopedTarget.personalia"]."" != ""' had error 'Expected identifier'
at Tridion.ContentManager.Templating.Expression.JScriptEvaluator.EvaluateToObject(String statement)
at Tridion.ContentManager.Templating.Expression.JScriptEvaluator.EvaluateToString(String statement)
Removing and replacing this identifiers is not solution acceptable by customer.
I was wondering what can be the best solution to cope this issue? Either using C# code to rendering component presentations, maybe create some custom rewrites( if it is possible because I got error from component presentations).
A similar thing happens if customers use JSP EL in their applications, which use the same ${...} syntax, and want to encapsulate this in their templates.
The most common solution is to replace this syntax with something like $[...] in the Dreamweaver templates and use a .Net TBB after the Dreamweaver template which uses string replacement or regular expressions to convert it.
See my gist for an example TBB that does this.
I normally use this code to "enable JSTL in templates". Since you can't change Tridion to use a different code identifier, you need to change your markup. Run this TBB at the END of your template to convert $[expression] to ${expression}
using System;
using System.Text.RegularExpressions;
using Tridion.ContentManager.Templating;
using Tridion.ContentManager.Templating.Assembly;
namespace TridionTemplates
{
[TcmTemplateTitle("Enable JSTL")]
public class EnableJSTL : ITemplate
{
private static readonly Regex JstlRegex = new Regex(#"\$\[.*\]");
public void Transform(Engine engine, Package package)
{
Item outputItem = package.GetByName(Package.OutputName);
string outputText = outputItem.GetAsString();
Match match = JstlRegex.Match(outputText);
while (match.Success)
{
String replaceJstl = match.Value.Replace("[", "{");
replaceJstl = replaceJstl.Replace("]", "}");
outputText = outputText.Replace(match.Value, replaceJstl);
match = match.NextMatch();
}
outputItem.SetAsString(outputText);
package.Remove(outputItem);
package.PushItem(Package.OutputName, outputItem);
}
}
}
If you absolutely can't change the syntax in your Dreamweaver templates (As I stated, I'm not sure I fully understand/agree with the reasons for that) then perhaps you could switch to using the Razor Mediator for your templating instead?
As I mentioned replacing syntax is not solution. I have solved this by rendering component presentation in separate C# tbb before Dreamweaver template. Off course,David suggestion is useful if you are allowed to change the syntax.
I use SDL Tridion 2011 SP1 HR1. TemplateBuilder version 6.1 Build 6.1.0.73.
Extract components from Page executed before DWT code below.
<!-- TemplateBeginRepeat name="Components" -->
##RenderComponentPresentation()##
<!-- TemplateEndRepeat -->
Output error logged from Template builder in case if component presentations contains ${sometext}.
JScriptException: Expression '""["scopedTarget.personalia"]."" != ""' had error 'Expected identifier'
at Tridion.ContentManager.Templating.Expression.JScriptEvaluator.EvaluateToObject(String statement)
at Tridion.ContentManager.Templating.Expression.JScriptEvaluator.EvaluateToString(String statement)
at Tridion.ContentManager.Templating.Package.EvaluateExpression(String expression)
at Tridion.ContentManager.Templating.Dreamweaver.DreamweaverMediator.TransformValueReferences(Package package, StringReference templateReference, Regex startTagExpression, String endTag)
at Tridion.ContentManager.Templating.Dreamweaver.DreamweaverMediator.TransformRegions(Package package, String dreamweaverTemplate)
at Tridion.ContentManager.Templating.Dreamweaver.DreamweaverMediator.Transform(Engine engine, Template templateToTransform, Package package)
at Tridion.ContentManager.Templating.Engine.ExecuteTemplate(Template template, Package package)
at Tridion.ContentManager.Templating.Engine.InvokeTemplate(Package package, TemplateInvocation templateInvocation, Template template)
at Tridion.ContentManager.Templating.Compound.CompoundTemplateMediator.Transform(Engine engine, Template templateToTransform, Package package)
at Tridion.ContentManager.Templating.Engine.ExecuteTemplate(Template template, Package package)
at Tridion.ContentManager.Templating.Engine.InvokeTemplate(Package package, TemplateInvocation templateInvocation, Template template)
at Tridion.ContentManager.Templating.Engine.TransformPackage(Template template, Package package)
at Tridion.ContentManager.Templating.Debugging.DebuggingEngine.Run()
at Tridion.ContentManager.Templating.Debugging.DebugSession.Run()
---Caused by:
Expected identifier
eval code: Line 1 - Error: Expected identifier

Is it possible to intermix Modular templating and legacy VBScript CT?

In particular, the case I have in mind is this:
##RenderComponentPresentation(Component, "<vbs-legacy-ct-tcm-uri>")##
The problem I'm having is that in my case VBS code breaks when it tries to access component fields, giving "Error 13 Type mismatch ..".
(So, if I were to give the answer, I'd say: "Partially, of no practical use")
EDIT
The DWT above is from another CT, so effectively it's a rendering of component link, that's why parameterless overload as per Nuno's suggestion won't work unfortunately. BTW, the following lines inside VBS don't break and give correct values:
WriteOut Component.ID
WriteOut Component.Schema.Title
EDIT 2
Dominic was absolutely wright: it's a missing dependencies.
A bit more insight to make this info generally useful:
Suppose, the original CT looked like this ("VBScript [Legacy]" type):
[%
Call RenderComponent(Component)
%]
This CT was meant to be called from a PT, also VBS-based. That PT had a big chunk of "#include" statements in the beginning.
Now the story changes: the same CT is being called from another, DWT-based, CT. Obviously (thanks you all for your invaluable help!), dependencies are now not being included anywhere.
The solution to make original CT working again is to explicitly hand-pick and include all necessary VBS TBBs, so the original CT becomes:
[%
#include "tcm:<uri-of-vbs-tbb>"
Call RenderComponent(Component)
%]
Yes - it's perfectly possible to mix and match legacy and modular templates. Perhaps obviously, you can't mix and match template building blocks between the two techniques.
In VBScript "Error 13 Type mismatch" is sometimes used as a secret code that really means "I don't recognise the name of one of your variables, (including the names of Functions and Subs)" In the VBScript templating engine, variables from the page template could be in scope in your component template; it was very common, for example, to put the #includes in the PT so they could be used by the CT. My guess is that your component template is trying to use such a Function, and not finding it.
I know that you can render a Modular Page Template with VBScript Component Presentations, and also a VbScript page template can render a modular Component Template.
Your error is possibly due to something else? Have you tried just using the regular ##RenderComponentPresentation()## call without specifying which template?
The Page Template can render Compound Templates of different flavors - for example Razor, VBS, or XSLT.
The problem comes from the TBBs included in the Templates. Often the Razor templates will need to call functions that only exist in VBScript. So, the starting point when migrating templates is always to start with the helper functions and utility libraries. Then migrate the most generic PT / CT you have to the new format (Razor, XSLT, DWT, etc). This provides a nice basis to migrate the rest of the Templates as you have time to the new format.

Resources