How to get HTML from precompiled Ember template? - ember.js

I have HTML code that I want to load on certain actions. It's a game and the user is able to switch between scenes. It is not possible to change routes for this, but I have to load HTML code for that scene from a template file.
All templates are precompiled with grunt-ember-templates in one JS file. I can access the according function via Ember.TEMPLATES["scene_name"], but it's a function with a lot of parameters - how can I use this? Or should I use "another way"?
Edit:
The pre-compiled template code like this.
Ember.TEMPLATES["scenes/bg1"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
data.buffer.push("much HTML code");
});
All I want is the content of the data Object.

Related

Recover hybrid page Alfresco Share

I've created a new page Aikau, but I changed the XML file and the rendered page content between the standard Share header and footer disappeared.
In this page, I want the arguments of the query string, so I write this code:
page.get.desc.xml:
<webscript>
<shortname>My New Page</shortname>
<url>/hdp/ws/my-new-page</url>
<authentication>user</authentication>
</webscript>
page.get.js:
function main ()
{
// Get the args
var fileProp = args["test"];
model.temp = fileProp;
}
main();
page.get.html.ftl:
Test arg: ${temp}
I have to put /hdp/ws/my-new-page in the XML file to write the content of FTL file in this page... But why did the header and footer of the Alfresco template disappeared ? hdp serves for this purpose. And if I don't put the URL like that on the XML, the page appears with the template.
What is wrong in my code? Or how can I recover the template? Or add header and footer?
EDIT: I already try to put only /my-new-page without /hdp/ws/ but the args are null when I put /hdp/ws/. Give me a hint.
EDIT2: I already try to import alfresco-template.ftl but I can't. Any idea?
You don't actually need to include the the "hdp/ws" part in your WebScript descriptor. Only the "/my-new-page" is required. Aikau attempts to simplify the Surf page creation by providing a number of pages out-of-the-box (and the "hdp" page is just one of them).
Aikau uses URI-template mapping to match a single WebScript to a page, so for example in the URL:
/share/page/hdp/ws/my-new-page
share = application context
page = Spring MVC request dispatcher
hdp/ws/my-new-page is then mapped to the URI template:
<uri-template id="share-page">/{pageid}/ws/{webscript}</uri-template>
Where "hdp" is the id of the page to render and "my-new-page" is the WebScript URL. The HDP page uses the "webscript" token from the template to automatically create a new Surf Component and bind it to the WebScript.
But in short - don't include "hdp/ws" in your WebScript URLs for Aikau pages.
You need to make the things that you have on javascript server in this javascript mandatorily? If not, you can create a javascript client that receive the same arguments (location.search give to you the query string, so, you can make parse of that query string and get only the value of the "test" that you want) and call them on FTL file (the client-side javascript). So, when the page loading, it does not lose the arguments. It isn't the best solution but you can try this...

how i make custom template in Drupal 7

I am new on drupal, Can you help me to make custom template in drupal and how i call this?
I want to create a custom template and how i call this in my node
and also please describe how the block call in under page content, there is any shortcode for block?
Hi create YouThemeName folder and put it in /site/all/themes/.
In theme folder create file YouThemeName.info and insert it:
name = YouThemeName
description = YouThemeDescription.
package = Core
version = VERSION
core = 7.x
// Regions
regions[header] = Header
regions[content] = Content
regions[footer] = Footer
And you new template is ready. For more inforamation please visit Drupal.org and read documentation.
Looks like you want to override some Drupal template? As of Drupal 7.33 there is theme debug mode, to enable just add row to your settings.php: $conf['theme_debug'] = TRUE; and then just open page for which you want to override template and open developer tools there(Use Ctrl+Shift+I (or Cmd+Opt+I on Mac)), you will see something like this http://take.ms/XOXZt and can identify which template to create and how to call it, more you can read here https://www.drupal.org/node/1089656
Creating custom template in drupal is super easy, you can create a file name like node--[type|nodeid].tpl.php and place it in templates folder of your theme.
Remaining drupal does the magic, your can do your stuffs in the custom template file. Similar way to create for custom block tempalte file too.
For more information you can check this url:
https://www.drupal.org/node/1089656

How can i use gantry object in chronoform?

I want to add css and js file in head. But my template is using gantry. So I need to use gantry object to add css and js. But this object is not accessible in my custom form code. I think my requireonce function can not include the file.
require_once('../../../../templates/rt_graffito/lib/gantry/gantry.php');
$gantry->init();
$gantry->addStyle('media/moo_rainbow/css/mooRainbow.css', 5);
$gantry->addScript('media/moo_rainbow/js/mooRainbow.js');
This is the code I am using in my chrono form. But it's not working.
I bet you can use core Joomla document object and gantry shall pick it up, try follow:
<?php
// ... some code here
$document = &JFactory::getDocument();
$document->addScript('media/moo_rainbow/js/mooRainbow.js');
$document->addStyleSheet( 'media/moo_rainbow/css/mooRainbow.css');
// ... other code
and documentation reference
http://docs.joomla.org/JDocument/addStyleSheet
http://docs.joomla.org/Adding_JavaScript

What a better way to handle templates in Ember.js, that isn't putting them in <script> tags?

So I'm building an Ember.js application. I've got more than two routers now, so it's becoming a lot harder to justify putting all these templates in index.html as <script> handlebars.
I can't seem to figure out how to have handlebar templates outside of the html! The other thing is that I'd like to avoid more dependencies if possible. So no pipeline, grunt libraries, or similar.
So to clarify:
I already stuff templates in index.html via <script> tags, I don't like it.
I don't want to jump back 20 years and put HTML in strings inside my javascript.
AJAXing static views seems ridiculous.
Without adding anything to the stack I don't see how you could do it other then putting them in index.html or in code one way or the other.
With adding stuff to your stack you should probably read this: answer by Yehuda Katz himself.
You could compile your templates in code like so:
App.View = Em.View.create({
template: Em.Handlebars.compile('{{outlet}}');
});
or if you are extending the view:
App.View = Em.View.extend({
defaultTemplate: Em.Handlebars.compile('{{outlet}}');
});
or you could register them like so
App.register('template', 'ViewName', Ember.Handlebars.compile(template));
The best way I've found so far is to use a command line tool like Grunt. You set the paths where your templates are (so you can organize your handlebars files nicely), and grunt will automatically compile all the views into a single, minified JS file that you can include, whenever you create or modify a template.
Because your templates are already compiled you can ship your application with a much smaller version of handlebars.
You can see an example of a configured Grunt file for that here : https://github.com/trek/ember-todos-with-build-tools-tests-and-other-modern-conveniences

Tell TYPO3 extension to use different template using Typoscript

I'm trying to get an extension/plugin on a page to use a different template from the one its hardcoded with.
I made an html template stored in:
typo3conf/ext/myextension/pi1/new_extension_template.html
I made a typoscript template object in the root of my site (so it would definitely get picked up).
In it, I have defined the following simple Typoscript (names changed for demonstration)
plugin.tx_myextension_pi1 {
templateFile = typo3conf/ext/myextension/pi1/new_extension_template.html
}
However when I load the page containing the plugin, I get a "no typoscript template found" error on that black TYPO3 error page.
I have tried a bunch of alternative ways in case the syntax was wrong but the above worked for me when working with the tt_news plugin.
E.g I have tried these without success too:
templateFile.file = typo3conf/ext/myextension/pi1/new_extension_template.html
...
tempfile.template_file = typo3conf/ext/myextension/pi1/new_extension_template.html
Any ideas what I'm doing wrong?
Can html templates stored in typo3conf be called via typoscript stored outside the plugin?
I'm thinking perhaps html template files would have to be stored in fileadmin/plugin_templates/ for this to work.
You are mixing things: no typoscript template found means that on the page you inserted the plugin there is no TS template available.
Page with plugin isn't nested under the main page (which - as I assume - has main TS template and is displayed properly), so just drag it into the main page, or create new TS template on its level.