Embed file content in ARM template - azure-resource-manager

I have an ARM template, which I use to deploy a resource which has a property that contains a Python script as a string. Instead of having the script in the template file, I would prefer to have it in a .py file, and embed that in the template on deployment.
Is there a way to achieve this?

The simplest way to do this is using loadTextContent() in bicep: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-functions-files#loadtextcontent
If you're not using bicep (and can't) there's no good substitution for it in JSON, you'd have to fashion something to parse the json, figure out where that goes and stringify yourself.
That help?

Related

File extension validation in Symfony3

Is there any already implemented way to validate file extension in Symfony? File and Image validators can only validate mime type. Is there any way to do it or do I have to use a custom validator / callback?
You could use a RegexValidator if all you want to validate about is the file extension. Do keep in mind that a file extension in no way guarantees the contents of the file. Someone could upload an executable as a .png for instance.
Example
new RegexValidator('/(.+)(\.jpg|\.png|\.gif)$/')
Will match any filename ending in .jpg, .png or .gif
If you want more control over it (for example, passing an array of allowed extensions) I would recommend using a CallbackValidator or making your own. Good luck!

overriding styles defined on production server for DITA XML files

Here is scenario I am working in.
Using Eclipse with IXIASoft DITA CMS and Oxygen XML editor.
Retrieve files stored in DITA CMS and edit in oxygen.
Generate pdf output. PDF creation is controlled by antennae house libraries on a production server and I do not have access to xsl stylesheets or css files on production server.
I tried embedding styles in dita file, but it appears that files on production server override whatever I do. Tried linking to local css file, but it too seems to be overridden.
Also limited by what is allowed in the custom DTD. Did find an outputclass attribute for the p element, but not sure how to use it. Any suggestions.
The PDF output generated via the DITA Open Toolkit (used also by Ixiasoft) is not related in any way to CSS styling. The DITA content gets translated to an XSL-FO format which then gets processed to PDF using a PDF processor like the default Apache FOP.
So you need access to the XSLT code on the server side in order to provide any PDF customization.
Usually a PDF customization without directly modifying the XSLT code from the DITA OT is done like this:
http://www.oxygenxml.com/doc/ug-oxygen/#topics/dita_pdf_output_customization.html
Regards,
Radu
If you cannot add a plugin to the DITA-OT image on the server, you're actually out of luck for changing the PDF output. If, however, you can create a plugin for the DITA-OT image used by Ixiasoft, and can run the ant integrator on that image, then you should be able to change those styles.
Keep in mind that overriding PDF is not for the faint of heart and if you have no experience with XSLT and XSL-FO, I suggest you get a consultant to help you.
Julio J. Vazquez
Write Spirit

How to use HTML inside of translatable strings in Qt?

The Qt tutorial for translatable texts does not mention whether it is possible to use HTML inside of a translatable string.
However, some examples I found use it, so it seems to be possible.
However, if I so much as use "<B>text</B>" in my .ts file, Qt Linguist does not open it. It displays the error message "unexpected tag" instead.
The ts file is XML. If you want to use HTML tags you will need to escape them. For example: <source><b>text</b></source>
Note that the recommended way of managing translations in Qt is to run the lupdate tool on your source code and have Qt generate the .ts file, in which case this will be done automatically.

Using directives in new files

Is it possible to have additional "using" directives automatically added to my new aspx.cs files so that I do not have to keep typing the same ones over and over again (i.e. custom namespace using directives)
You can edit the files that are used by the template. Better yet, create your own. File + Export Template.
You don't have to type them in. When writing the code, type in the name of the class (without the namespace). Then hit CTRL+.. That will open up the resolve type intellisense helper. It will add the using statement to the top of the file. No scrolling necessary.

How to access serverside context from `.js` file?

I have to move all my scripts into a separate .js file. But I have wired the code in the client (*.aspx) file, with code such as
<script>
var x=<%=ViewData["Key"];%>
</script>
I'm sure there will be an issue when I move that line to the js file as the server side context can't be accessed.
How do I solve this issue?
The most straightforward thing to do is to move all JS code except these variable assignments.
Effectively, the trick is dependency injection in javascript. First, abstract the variables you are generating from server-side variables into parameters for your javascript methods and objects. Then use a small amount of script in-page to setup the javascripts to run.
If you are dealing with a few rather static things (eg--some path names), another tactic is to create a javascript "configuration" object that is in a separate, server-generated script, that can be called by your other scripts as needed.

Resources