run time error when embedding monaco editor in ember app - ember.js

I am trying to use monaco-editor in my ember app,
I am using
ember-monaco for that.
I followed the instructions and added in my application.hbs the following code:
{{code-editor
language="typescript"
code=sample1
onChange=(action (mut sample1))
theme="light"
onReady=(action editorReady)
}}
I am running the app, but the editor doesn't appear,
I get the following runtime error:
index.js:181 Uncaught Error: Assertion Failed: Action passed is null or undefined in (action) from (generated application controller).
at assert (index.js:181:1)
at makeClosureAction (index.js:738:1)
at makeDynamicClosureAction (index.js:727:1)
at index.js:679:1
at Object.evaluate (runtime.js:2084:1)
at AppendOpcodes.evaluate (runtime.js:1312:1)
at LowLevelVM.evaluateSyscall (runtime.js:5232:1)
at LowLevelVM.evaluateInner (runtime.js:5188:1)
at LowLevelVM.evaluateOuter (runtime.js:5180:1)
at VM.next (runtime.js:6191:1)
I removed the actions
{{code-editor
language="typescript"
code=sample1
theme="light"
}}
Now the editor appears but with out the sample code (since I deleted the relevant lines),
What is the correct syntax?
Ember version:
ember-cli: 3.28.5
node: 10.24.1

with ember-source#3.16+, it's recommend to directly reference actions / functions, like:
{{code-editor
language="typescript"
code=this.sample1
onChange=this.handleChange
theme="light"
onReady=this.editorReady
}}
(assuming handleChange and editorReady are defined your backing class) (also assuming you have a backing class)

Related

WebStorm does not suggest autocomplete based on TypeScript types for some reason

Just started a fresh new React project, using WebStorm as my IDE.
Lets look at some type of material-UI typography 'varient' attribute:
For an unknown reason, WebStorm does not peek at these types:
('no suggestions' is written buy when I screenshot the message disappear)
VSCode auto-suggest with no problems on this union type:
What's going on? I know for sure that these sort of suggestions worked previously in WebStorm (I'm using latest version).
This is the code:
import { Typography } from "#mui/material";
function App() {
return (
<div className="App">
<Typography variant="">hello world, doing good?</Typography>
</div>
);
}
export default App;
WEB-53199 is fixed in the upcoming 2021.3.2 update

CakePHP Exception change template

How to replace just one exception template for own exception inside a plugin, which is extended built-in exception? :)
Exception located is in /vendor/author/pluginName/src/Exception/TestException.php
But i try replace template by create file /src/Template/PluginName/Error/test.ctp but doesn't work.
Of course, if I create file inside /src/Template/Error/test.ctp works fine.
I have many plugins and each can has own TestException class.
So, How I can use /PluginName direcotry?
Cake 3.6
The correct template path for overriding a plugin template on app level starts with Template/Plugin/, followed by the plugin name and the expected local template path, ie for a plugin named Foobar, the path for overriding its test error template would be:
src/Template/Plugin/Foobar/Error/test.ctp
Also it's important to keep in mind that error templates will by default only be looked up in plugins, if the exception is being triggered in a plugin controller request, to be specific, when the current global request object (Router::getRequest(true)) has a plugin parameter set ($request->getParam('plugin'))!
It should also be noted that individual templates that map to exception/method names, will only be used for non-HTTP exceptions (\Cake\Http\Exception\HttpException), and only when debug mode is enabled, if it's a HTTP-Exception or debug mode is disabled, then only the error400 or error500 template will be used!
See also
Cookbook > Plugins > Plugin Views > Overriding Plugin Templates from Inside Your Application

Strange behavior in ember 1.13.*

I have a controller ApplicationController with controllerInt and controllerString properties.
And I have a component RedSquareComponent with componentInt and componentString properties.
I bind controllerInt and controllerString to componentInt and componentString via hbs-template, componentString=controllerString="VALUE FROM CONTROLLER".
In RedSquareComponent I also have .on('init') method which set "SET ON INIT" value to componentString.
I've added an action to component to handle click on some object (red square) and set some value (for example, 1) to componentInt.
But when this action works -- componentString also changes (I don't know why), and become equal to "VALUE FROM CONTROLLER".
Is it a really expected behaviour?
The same code works fine on Ember 12.4, but I have checked it on several 13.* versions - it doesn't work.
https://jsfiddle.net/AlexeyBedonik/a23ev98w/3/
In your case, if you just change .on('init') part to .on('didInsertElement') it will fix your problem.(that means it will update both controller and component componentString property to 'SET ON INIT'.)
But you should not change values on a parent that are rendered already is deprecated. so you will get deprecation warning.
To get more info about this issue/bug follow this discussion.
It's good to follow/understand below concepts.
1) Passing properties to component by default it is two-way data binding
2) To update data always follow the Data Down Actions Up priniciple (DDAU)

silverstripe Sitetree onAfterWrite - renderWith Error: Template not found

for the automated generation of pdfs from the page content I want to use the renderWith function within onAfterWrite in the Page Class (later with DOMPDF the PDF will be generated from the returned HTML):
public function onAfterWrite() {
parent::onAfterWrite();
$this->renderPdf();
}
public function renderPdf() {
return $this->renderWith(array('Pdf'));
}
There is always this Error returned when saving the Page: None of these templates can be found in theme 'mytheme': Pdf.ss
The Template exists for sure and calling the Function renderPdf via a Template works perfectly. This is a bit weird. (ss 3.1.1)
many thanks,
florian
EDIT: maybe it is related to 3.1, I just tested in 3.0.5. without any issues. In a clean 3.1.2 install I was able to reproduce the error.
Where is your template located exactly?
Have you tried to put it under the 'templates' folder, and not under 'Layout' or 'Includes'?
In your case, I would try to move that file here:
/themes/mytheme/templates/Pdf.ss
As you are calling for a standalone template (so not alongside 'Page' for example), the .ss file should be accessible as a 'root' template, as opposed to a layout template.

Infuser is not defined

I am trying to use Knockout external template plugin. Firefox stops in my util.js on this line: infuser.defaults.templateUrl = "/CAS/templates";
It complains that infuser is undefined. If I simply press continue in Firebug, the view loads and loads the template just fine. If I comment that line out, the template does not load and I get a file not found error. So that setting is working despite infuser is not defined. Here is the order stuff gets loaded.
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/external/jquery-{version}.js",
"~/Scripts/external/jquery-ui-1-10.2.js",
"~/Scripts/external/jquery.unobtrusive*",
"~/Scripts/external/jquery.validate*"));
bundles.Add(new ScriptBundle("~/bundles/knockout").Include(
"~/Scripts/external/knockout-{version}.js",
"~/Scripts/external/koExternalTemplateEngine_all.js",
"~/Scripts/local/utils.js",
"~/Scripts/external/knockout.mapping-latest.js"));
bundles.Add(new ScriptBundle("~/bundles/local").Include(
"~/Scripts/local/ajaxservice.js",
"~/Scripts/local/DMS.CAS.Dataservice.js",
"~/Scripts/local/DMS.CAS.ViewModel.js",
"~/Scripts/local/DMS.Models.js"));
Here is binding in the view:
<div data-bind="template: {name: 'HelloWorld'}"></div>
My jQuery version is 2.0.3, KO version is 2.3.0, and the KO External Template plugin was installed via nuGet 1 day ago. I have pursued this as problem with the order script files being loaded in the wrong order. But, that does not seem to be the case. Any help is appreciated.
You need to put infuser.js into Knockout bundle before koExternalTemplateEngine_all.js:
bundles.Add(new ScriptBundle("~/bundles/knockout").Include(
"~/Scripts/external/knockout-{version}.js",
"~/Scripts/external/infuser.js",
"~/Scripts/external/koExternalTemplateEngine_all.js",
"~/Scripts/local/utils.js",
"~/Scripts/external/knockout.mapping-latest.js"));