All the templates are stored in database. And i have to fetch contents of a template from database and marked up with freemarker. The end output will be rendered in a textbox.  But, i am not finding any methodology by which i can send string instead of file name.  Please suggest.
121020
I would like to store my FreeMarker templates in a database table that looks something like:  template_name | template_content --------------------------------- hello         |Hello ${user} goodbye       |So long ${user}   When a request is received for a template with a particular name, this should cause a query to be executed, which loads the relevant template content. This template content, together with the data model (the value of the 'user' variable in the examples above), should then be passed to FreeMarker.  However, the  seems to assume that each template name corresponds to a file of the same name within a particular directory of the filesystem. Is there any way I can easily have my templates loaded from the DB instead of the filesystem?  EDIT: I should have mentioned that I would like to be able to add templates to the database while the application is running, so I can't simply load all templates at startup into a new StringTemplateLoader (as suggested below).
123057
I am using hook_theme_suggestions_HOOK() to implement a custom template file in my drupal 8 website like below.   /**  * Implements hook_theme_suggestions_HOOK().  */ function mymodule_theme_suggestions_page(array $variables) {   $template_suggestions = array();   // This is used to display only $content.   if (isset($_GET['ajax']) &amp;&amp; $_GET['ajax'] == 1) {     $template_suggestions[] = 'page__ajax';   }   return $template_suggestions; }   Above code is working fine and I can add template page--ajax.html.twig inside my current active theme and changes in template is reflecting in page.  But when I put that file inside my module itself file is not detecting and changes not reflecting in page and taking default page.html.twg template file.  How can I provide default template file within my module itself?
108846
I'm  having some trouble editing the content of a Managed Email Template, I can quite easily modify the content of the Email Template, but when I wish to refer to an unmanaged component, like this:  &lt;messaging:attachment renderAs="PDF" filename="invoice.pdf"&gt;     &lt;c:MyComponent/&gt; &lt;/messaging:attachment&gt;   I get the error message:     Error: Unknown component c:mycomponent   Does anyone know if its possible to embed an unmanaged component in a managed Email Template?
4437
I have a requirement to show  page message for a particular selected template. The template selection done here. But render is always returning true in this case. Can someone help me here?  &lt;apex:selectList id="chooseTempalte" label="Choose Template" title="Select your Template"        value="{!selectedTemplateId}" size="1" onChange="rerenderEmailFields(this.value)"&gt;    &lt;apex:selectOptions value="{!TemplateOptions}"/&gt; &lt;/apex:selectList&gt;  &lt;apex:outputLabel style="color:red;"  rendered="{!IF(selectedTemplateId='Update Status - Send to ABSM', false, true)}" &gt;     Please note this selected option  will set the status value to Under Review &lt;br/&gt;&lt;br/&gt; &lt;/apex:outputLabel&gt;   Please find the apex controller snippet here.  public List&lt;SelectOption&gt; getTemplateOptions() {         options = new List&lt;SelectOption&gt;();         for (EmailTemplate t : etMap.values()) {             options.add(new SelectOption(t.Id,t.Name));             if((selectedTemplateId == '' || selectedTemplateId == null) &amp;&amp; t.Name == 'Update Status - Send to ABSM')             {                 selectedTemplateId = t.Id;                 ApplyTemplate();             }         }      return options; }
95527
Publishing pdf manuscripts on the web with emails embedded in the file results in spam.  More generally, I am looking for a way to automate the conversion of a string to an image.  It's quite easy to solve this old problem using  (more ). The trouble is that you need a distinct file and typesetting run, and you end up with unnecessary image files that you cannot delete carelessly lest you also delete non-generated images.  Can you think of a way to do this on the fly? It's understood that people will have to type the email addresses if they need to message you, but that's the point.  More briefly/concretely...  With what can one replace #1  \documentclass{article} \newcommand\showasimage[1]{#1} \begin{document} \showasimage{joe@foo.bar} \end{document}   such that #1 appears as an image?  Edit  It would be really nice if the pdf file remains vectorial.
93459
I have a dll that contains a templated class. Is there a way to export it without explicit specification?
41930
I would like to reproduce the "Save site as template" action with the client object model. Can someone give me a hint how to do this?
44509
This is a little confusing to explain, so bear with me here...  I want to set up a system where a user can send templated emails via my website, except it's not actually sent using my server - it instead just opens up their own local mail client with an email ready to go. The application would fill out the body of the email with predefined variables, to save the user having to type it themselves. They can then edit the message as desired, should it not exactly suit their purposes.  There's a number of reasons I want it to go via the user's local mail client, so getting the server to send the email is not an option: it has to be 100% client-side.  I already have a mostly-working solution running, and I'll post the details of that as an answer, I'm wondering if there's any better way?
4045
What is the most efficient way to write the old-school:  StringBuilder sb = new StringBuilder(); if (strings.Count &gt; 0) {     foreach (string s in strings)     {         sb.Append(s + ", ");     }     sb.Remove(sb.Length - 2, 2); } return sb.ToString();   ...in LINQ?
38806
The input in file field.html.twig is normally like this:  {% for item in items %} &lt;div{{ attributes }}&gt;{{ item.content }}&lt;/div&gt; {% endfor %}   And you get the output in HTML like this:  &lt;div&gt;&lt;img src="path/to/image/image.png" alt="my wonderful image"&gt;&lt;/div&gt;   But I want to add a class to img-tag. How do I receive the following output:  &lt;div&gt;&lt;img class="img-fluid" src="path/to/image/image.png" alt="my wonderful image"&gt;&lt;/div&gt;   I am looking for a solution like , but it is not working. Can anybody help?
47286
In WebForms, I would normally have code like this to let the browser present a "Download File" popup with an arbitrary file type, like a PDF, and a filename:  Response.Clear() Response.ClearHeaders() ''# Send the file to the output stream Response.Buffer = True  Response.AddHeader("Content-Length", pdfData.Length.ToString()) Response.AddHeader("Content-Disposition", "attachment; filename= " &amp; Server.HtmlEncode(filename))  ''# Set the output stream to the correct content type (PDF). Response.ContentType = "application/pdf"  ''# Output the file Response.BinaryWrite(pdfData)  ''# Flushing the Response to display the serialized data ''# to the client browser. Response.Flush() Response.End()   How do I accomplish the same task in ASP.NET MVC?
983
I have some template code that I would prefer to have stored in a CPP file instead of inline in the header.  I know this can be done as long as you know which template types will be used.  For example:  .h file  class foo { public:     template &lt;typename T&gt;     void do(const T&amp; t); };   .cpp file  template &lt;typename T&gt; void foo::do(const T&amp; t) {     // Do something with t }  template void foo::do&lt;int&gt;(const int&amp;); template void foo::do&lt;std::string&gt;(const std::string&amp;);   Note the last two lines - the foo::do template function is only used with ints and std::strings, so those definitions mean the app will link.  My question is - is this a nasty hack or will this work with other compilers/linkers? I am only using this code with VS2008 at the moment but will be wanting to port to other environments.
121685
How to fetch HTML in C or C++? with Sockets. Can you give me a Example code pls?  NOTE - I originally closed this, but reopened.  To the poster - Please see:    and
86062
How can I display an image which is stored in files?  For attachments I can use the code below, but it doen't work for files.  &lt;apex:image id="Stat1" URL="/servlet/servlet.FileDownload?file=0698E0000008w5e" width="15" height="15"/&gt;
122345
I am working on a (my first) Drupal 8 project witch is a multilingual site. Drupal 8 really delivers in terms of native support for content translation.  However, I have a few strings set directly in some if the theme .Twig template files printed out like ex.   {{ 'Read more'|trans }}   I am really stuck on where to handle the translation for strings like these within the Drupal 8 installation.  What steps do I need to take to be able to translate these strings into the language currently selected for on the site? Do I need any additional modules other than the ones included in Drupal 8 core?  Steps I have taken:   Activated the Content Translation &amp; Interface Translation modules Added Twig strings like {{ 'Read more'|trans }} Flushed cache and refreshed pages containing the strings Checked admin/config/regional/translate for the strings with no result
103246
I can't seem to call the objects out on the database and onto a visualforce page using this set up:   public with sharing class HarborEventController {  private final Event__c event; public HarborEventController(ApexPages.StandardController controller) {     this.eventlist = (Event__c)controller.getRecord(); }   public Integer eventcount{get;set;} public HarborEventController (){    eventcount = [SELECT COUNT() FROM Event__c];     }   public list&lt;Event__c&gt; mainlist {get;set;}   public list&lt;Event__c&gt; displayevents(){     mainlist = new list&lt;Event__c&gt;();     String mainsoql = 'SELECT Id, Name__C, Message__c, Display_Date__c, FROM Event__c';      mainsoql += 'ORDER BY Display_date__c LIMIT :5';     mainlist = Database.query(mainsoql);     return mainlist; }   and the visualforce page :           &lt;apex:composition template="eh_base"&gt;           &lt;apex:define name="heros-content"&gt;             &lt;/apex:define&gt;       &lt;apex:define name="content"&gt;        &lt;section id="services-sec"&gt;          &lt;div class="container"&gt;             &lt;div class="row" style="padding-top: 60px;"&gt;       &lt;apex:outputPanel layout="block" rendered="{!AND(NOT(ISNULL(mainlist)),mainlist.size&gt;0)}"&gt;         &lt;apex:form id="blockofeventtorepeat"&gt;             &lt;apex:repeat value="{!mainlist}" var="evententry" id="repeat"&gt;                 &lt;div class="col-md-9"&gt;                    &lt;h3&gt;&lt;apex:outputLink styleClass="evententry-header block" value="{!$Page.eh_eventdetails}?id={!evententry.id}"&gt;{!evententry.Name__c}&lt;/apex:outputLink&gt;&lt;/h3&gt;                     &lt;apex:outputPanel &gt;                      &lt;p&gt;                          &lt;img src="{!URLFOR($Action.Attachment.Download, evententry.Attachments[0].Id)}" class="pull-left img-responsive" alt="" style="max-width:180px;max-height:100px"/&gt;                         {!evententry.Message__c}                      &lt;/p&gt;                        &lt;apex:outputLink styleclass="btn btn-sm btn-default" value="{!$Page.eh_eventdetails}?id={!evententry.id}"&gt;Read More&lt;/apex:outputLink&gt;                      &lt;/apex:outputPanel&gt;                 &lt;/div&gt;                 &lt;/apex:repeat&gt;                 &lt;/apex:form&gt;                 &lt;/apex:outputPanel&gt;                   &lt;/div&gt;             &lt;/div&gt;                 &lt;/section&gt;           &lt;/apex:define&gt; &lt;/apex:composition&gt;     Can anyone suggest how I can able to get the event data from the query and display it on a visualforce page in a repeat tag? I've tried everything and it doesn't work.  I've already tried passing the query from an anonymous user and the results were as expected
104259
I am currently working on a project to create a (not prepaid) postage label.  In java, I would go about doing this by creating a bufferedimage and adding various other images to it to create what I want.  What I want is to put text, converted to an image, onto a template letter, to make a proper postage label.    For example, imagine I was given a document with blank spaces such as:  "Name: _________"  This document is in the form of an image, and I want to use apex and visualforce (the page is already constructed, I am just stuck at the image manipulation part) to add whatever name the user types in onto the image and pack it and email the new image.  The question I have here is: where do I even start?  Java is a little nicer when it comes to image manipulation, as far as I can see.  I've looked into using a web service and sending a soapxml request to return a proper encoded image, but I haven't found a web service that can do this.  Any pointers would be nice. Thanks.