ReferenceError: JST is not defined in Sails.js - sails.js

I have an ejs javascript template in:
/assets/linker/template
I changed the line in gruntfile.js from:
linker/**/*.html to linker/**/*.ejs
I have underscore.js in:
assets/linker/js
But when I try:
JST['assets/linker/templates/addUser.ejs']( obj ) from app.js
I get this error in the console:
ReferenceError: JST is not defined
Any help would be appreciated! Thanks!

I had the same problem. I solved it by manually linking JST into my index.ejs file.
so I just added
<script type="text/javascript" src="/jst.js"></script>
where I load my javascripts in sailsProject>views>home>index.ejs.
Not pretty, as the linker should do the job, but for now it works.
cheers

The Pipeline
The template files that are injected are specified in tasks/pipeline.js
The default is set to:
var templateFilesToInject = ['templates/**/*.html']
Files in assets/templates (or any subdirectory) with the .html file extension are injected.
Also check out the JST task in tasks/config/jst.js. It takes the template files to inject (from pipeline.js) and precompiles them into a file called jst.js.
Only once these other tasks have completed does the sails-linker begin its task. tasks/config/sails-linker.js takes the jst.js that was generated by the JST task and includes it into the template start and template end tag in .tmp/public/index.html, views/**/*.html, and views/**/*.ejs.
So the default pipeline for client-side templates is:
Precompile templates/**/*.html into jst.js
Include jst.js in index.html, views/**/*.html, and views/**/*.ejs between <!--TEMPLATES--> and <!--TEMPLATES END-->
Customization Examples
All of this default configuration can be changed to suit your needs. For example, to have templates with a different extension or multiple extensions edit the templateFilesToInject in tasks/pipeline.js:
let templateFilesToInject = [
'vendor/templates/vendor_template.html',
'templates/**/*.ejs',
'templates/**/*.html'
]
Or to only inject templates on specific views if they have the comment <!--TPL--><!--END TPL-->, edit the devTpl config in tasks/config/sails-linker.js:
// Bring in JST template object
devTpl: {
options: {
startTag: '<!--TPL-->',
endTag: '<!--END TPL-->',
fileTmpl: '<script type="text/javascript" src="%s"></script>',
appRoot: '.tmp/public'
},
files: {
'views/that/use/templates/**/*.ejs': [
'.tmp/public/jst.js'
]
}
}

Related

TYPO3 Form Multicheckbox Partial

I tried to edit the core file form\Resources\Private\Frontend\Partials\Field\Field.html to change the html output in the frontend. If I change that file, it has not effetcs. If I change the core file form\Resources\Private\Frontend\Partials\Textarea.html it effects the output in the frontend.
I've tried to set a custom partial, layout and templates folder like this:
I've set the following in the setup part of the page template:
plugin.tx_form {
settings {
yamlConfigurations {
# register your own additional configuration
# choose a number higher than 30 (below is reserved)
100 = fileadmin/my_site_package/Configuration/Form/CustomFormSetup.yaml
}
}
}
In fileadmin/my_site_package/Configuration/Form/CustomFormSetup.yaml I have
TYPO3:
CMS:
Form:
prototypes:
standard:
formElementsDefinition:
Form:
renderingOptions:
templateRootPaths:
20:'fileadmin/my_site_package/Resources/Private/Templates/Form/Frontend/'
partialRootPaths:
20: 'fileadmin/my_site_package/Resources/Private/Partials/Form/Frontend/'
In the folder fileadmin/my_site_package/Resources/Private/Partials/Form/Frontend/ I have the copied Multicheckbox.html and the other copied partial files from the form core folder. I have edited the Multicheckbox.html, but it has not effects to the frontend.
Thank you so much for your input. The problem was because of the bootstrap package. There was a file Multicheckbox.html in the folder "typo3conf/ext/bootstrap_package/Resources/Private/Partials/Form". This one overrided the core file Multicheckbox.html
But what am I doing wrong in my steps? I'm getting now the following error in the frontend:
Oops, an error occurred!
Tried resolving a template file for controller action "FormFrontend->form" in format ".html", but none of the paths contained the expected template file (FormFrontend/Form.html). No paths configured.
More information regarding this error might be available online.
Did I set the paths in CustomFormSetup.yaml wrong?
I've also tried
TYPO3:
CMS:
Form:
prototypes:
standard:
formElementsDefinition:
Form:
renderingOptions:
templateRootPaths:
1:'/my_site_package/Resources/Private/Templates/Form/Frontend/'
partialRootPaths:
1:'/my_site_package/Resources/Private/Partials/Form/Frontend/'
with the same error.

Loading library.js from bad path

I have updated OpenUI5 of my project from 1.42.7 to 1.60.12 (LTS)
If I try to run the app with the new version, I have this error:
Uncaught Error: failed to load 'sap/ui/core/library.js' from resources/sap/ui/core/library.js: 404 - Not Found**
The tree structure of my project has OpenUI5 files into resources/openui path:
In index.html, I set src in this mode:
<script id="sap-ui-bootstrap"
src="resources/openui/sap-ui-core.js"
data-sap-ui-theme="sap_belize"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-libs="sap.m"
data-sap-ui-preload=""
data-sap-ui-resourceroots='{
"ui5bp": "./",
"model": "./model"
}'
></script>
It seems that the first call of sap-ui-core.js finishes correctly (from Webcontent/resources/openui) but then the call of library.js is called from Webcontent/resources/, not from Webcontent/resources/openui.
In 1.42 version, all works fine.
Note: if I try to retrieve OpenUI5 resources from CDN, all works fine...
src="https://openui5.hana.ondemand.com/1.60.12/resources/sap-ui-core.js"
Option 1 (recommended)
Move the UI5 resources to the resources folder directly underneath.
˅ 📂resources
˃ 📁openui
˅ 📂sap
˃ 📁base
˃ 📁f
˃ 📁m
...
...
sap-ui-core.js
According to the topic Bootstrapping: Loading and Initializing - Initialization Process, UI5 will try to fetch library resources from the following path by default:
Library bootstrap file /<context-path>/resources/<library-name>/library(-preload).js
Having a deviating path (/resources/openui/<library-name>/ in between) makes fetching the library files incompatible with default settings.
Option 2 (without changing the folder structure)
Define a new default base URL in index.html as early as possible. E.g. via the global configuration object:
<script>
window["sap-ui-config"] = {
resourceRoots: {
"": "./resources/openui/", // <-- new base URL
"ui5bp": "./",
// ...
},
libs: "sap.ui.core, sap.m",
async: true,
theme: "sap_belize",
compatVersion: "edge",
// ...
};
</script>
<script id="sap-ui-bootstrap" src="resources/openui/sap-ui-core.js"></script>
This one works too as resolving "" will always work as a fallback
Note that the empty prefix ("") will always match and thus serves as a fallback for any search. source

How to get Codeigniter 3 to use project root instead of referencing full file path on localhost for key folders

I've looked around and I'm sure this is common but can't seem to get the right answer.
I've just recently set up a Codeigniter 3 project on my localhost and a migrating some Codeigniter 2 code.
The index.php file is a bit different.
I can get the project up and running except the main folders references in the index.php file such as APPLICATION and others I've added like "ASSETS" etc are loading like this:
<link href="http://[::1]/projectOne/E:\public_html\projectOne\assets\css\style.php?1537317115" rel="stylesheet" type="text/css" >
Even when I set a base_url:
<link href="http://localhost/projectOne/E:\public_html\projectOne\assets\css\style.php?1537317115" rel="stylesheet" type="text/css" >
I've checked it wasn't just the folders I added by echoing out the APPPATH variable:
define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
echo APPPATH;
Which produces:
E:\public_html\projectOne\application\
What am I missing here?
How do I get my paths to folder set in the index.php to just use the project root, and not the whole filepath on the computer?
Figured it out. For anyone else that hits this issue.
This new part in CI3:
if (($_temp = realpath($application_folder)) !== FALSE)
{
$application_folder = $_temp;
}
Allows you to more securely/easily have your application folder outside of the website root.
My additional ASSETS folder was then showing the full web path which you obviously don't want.
So commenting out this part leaving only:
$application_folder = strtr(
rtrim($application_folder, '/\\'),
'/\\',
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
);
And then setting you base_url value in the config.php file gives your CSS, JS and IMAGES proper site relative paths.

Include node module as a file to inject

I want to include /node_modules/es6-shim/es6-shim.min.js into the client side in Sails v0.11.
I've tried including it into the pipeline as such:
var jsFilesToInject = [
// Load sails.io before everything else
'js/dependencies/sails.io.js',
/* INCLUDE NODE MODULE */
'/node_modules/es6-shim/es6-shim.min.js',
// Dependencies like jQuery, or Angular are brought in here
'js/dependencies/**/*.js',
// All of the rest of your client-side js files
// will be injected here in no particular order.
'js/**/*.js',
// Use the "exclude" operator to ignore files
// '!js/ignore/these/files/*.js'
];
Is this possible? I don't really want to use bower or a CDN, I would like to install/update the dependency via npm.
The simplest way to accomplish this would be to leave the pipeline.js file alone and just make a symlink inside of assets/js pointing to the file you want, e.g.:
ln -s ../../node_modules/es6-shim/es6-shim.min.js assets/js/es6-shim.min.js
Next time you run sails lift, Grunt will see the new Javascript file in your assets/js folder and process it with the rest.
If this is for some reason not an option, you'll need to add a new subtask to the tasks/copy.js Grunt task:
dev_es6: {
files: [{
expand: true,
src: ['./node_modules/es6-shim/es6-shim.min.js'],
dest: '.tmp/public/js'
}]
}
and then add that to the compileAssets task in tasks/register/compileAssets:
module.exports = function (grunt) {
grunt.registerTask('compileAssets', [
'clean:dev',
'jst:dev',
'less:dev',
'copy:dev',
'copy:dev_es6', // <-- adding our new subtask
'coffee:dev'
]);
};

How to change the config file for MathJax in doxygen?

I am using doxygen 1.8.9.1 and want to use AsciiMath in the hmtl output. It requires me to use a new config file, i.e. http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=AM_HTMLorMML. However, the configuration "MATHJAX_RELPATH" can only set the root path of mathjax.
How could I change the config to mathjax? Thanks for any suggestions.
EDIT:
I have tried to use MATHJAX_CODEFILE to change the config file "config: ["local/local.js","MMLtoHTML.js"]", but don't work for me. The URL should be modified, not just the configuration files. (i.e. MathJax.js?config=AM_HTMLorMML).
BTW: The render html should be change from \[sum_(i=1)^n i^3=((n*(n+1))/2)^2\] to `sum_(i=1)^n i^3=((n*(n+1))/2)^2`.
One solution is to modify MATHJAX section of footer.html in the Doxygen folder.
For example, use this to modify the url to MathJax.js?config=local/local.js
<!-- BEGIN MATHJAX-->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script><script type="text/javascript" src="../mathjax/MathJax.js?config=local/local.js"></script>
<!-- END MATHJAX-->
The $mathjax line of header.html should also be deleted.