Log Twig errors on strict_variables in Symfony - twig

In Symfony, Twig is configured with strict_variables to false in production mode.
However those errors are not logged in Monolog. Is there a way to make Twig log strict_variables errors?

Related

How do I add my view engine(ejs) to a combination of express and web pack dev server?

I am trying to integrate ejs to a express and web pack dev server project, and I am unable to do so because even though I am passing my variables, they are loading like this
Html Webpack Plugin:
ReferenceError: name is not defined
- index.ejs:102 ./node_modules/html-webpack-plugin/lib/loader.js!./src/templates/views/index.ejs.module.exports
C:/Users/arora/OneDrive/Documents/Rishab/Projects/Webpress/src/templates/views/index.ejs:102:11
- index.js:284
[Webpress]/[html-webpack-plugin]/index.js:284:18
- task_queues.js:93 processTicksAndRejections
internal/process/task_queues.js:93:5
This Error is in the console. Please help, here is the code link. Thanks in advance.
When webpack compiles your ejs to HTML it has no local variables passed to the template, and so you get this error. If you know the variables in advance you can likely pass these as options in webpack --- see ejs-html-loader.
If you're want to still use variables passed to the page via ejs you will want to use a separate "template" ejs file that is really barebones --- just to pass data into <script>.
If you want to continue passing variables into your "html" of the page you will need to use some sort of ejs loader keep the ejs output in some fashion, which might limit your options on what loaders you can use for other webpack optimizations.

STRAPI : currentEnvironment name in admin ui

I want to hide some menu from left navigation in production mode.
I've tried NODE_ENV, process.env, NODE_ENV etc. When I'm trying NODE_ENV, it returns production in development and production mode both. Any way to get config in admin ui? I can get environment name in controller using proces.env but I don't know how to send data from controller to admin ui.
I can get it in controller using process.env.NODE_MODULE or strapi.config but it's not accessible in react admin ui.
This is possible with webpack and can be done using following blog: https://medium.com/#justintulk/passing-environment-variables-into-your-code-with-webpack-cab09d8974b0
In webpack file you can fetch the env variables using the following link:
https://webpack.js.org/guides/environment-variables/

Node - Override function in all files except one

I've been looking around at somehow disabling console.log in my application while running unit tests, and I found answers that say you can override the console.log like this:
console.log = function(){};
I tried putting this in app.js, and it overrides console.log when I'm running the app, but not when running unit tests, so I tried adding it the to test file, but then it overrides mocha / chai's console.log, and I get a blank screen.
Is there a way to override the console.log in all files except the one running?
What you would probably want to do instead is use a logging library like Loggly or Bunyan. With these you pass the message you want to log to the client and then you can output those logs based on the environment you are in. In your case you want to log during production but not during testing (kindof odd, but whatever). So you would set process.NODE_ENV to dev or prod accordingly and the logger would take care of the logging for you. Here's an overview of some loggers.

jasmine-jquery fixtures not loading

Problem is that jasmine-jquery in not loading my fixtures from spec/fixtures folder. Now when I look at jasmine-jquery source code default path for fixtures is spec/javascripts/fixtures.
In a version that I have, there is no spec/javascripts/fixtures folder. It seems it is something for Ruby gem. I also tried to create that javascripts folder but still it can't load it. When I place my fixture fragment inside of SpecRunner.html body - it works.
Here is my html fragment:
<ul class="fr">
<li></li>
</ul>
Spec file:
describe("something to describe", function() {
it("should see a DOM element", function() {
loadFixtures("custom.html");
expect($(".fr")).toExist();
});
});
Is that a bug or something with the path ?
Solved:
It is a problem with google-chrome. By default it doesn't allow access to other domain by same origin policy. Solution is to run app from local server, or to use firefox.
It indeed has to do with Chrome. This is a security concept called Same-Origin Policy.
Instead of running Firefox or the app from local server, you can still use Chrome with that security check disabled.
Just run Chrome/Chromium with the command-line argument --allow-file-access-from-files:
google-chrome --allow-file-access-from-files
Remember! Since this is a security feature, by disabling it you are putting your computer at risk. It is recommended to only use this parameter when testing local websites/apps (via a different shortcut/alias).

Where to find express.js settings

I'm almost ashamed to ask this, but where can I find information about the settings for express.js? According to the documentation I can use app.set(name, setting) to assign setting name to setting, however I can't find anywhere which settings there are and how they work.
You can find it here:
http://expressjs.com/api.html#app-settings
settings
The following settings are provided to alter how Express will behave:
env Environment mode, defaults to process.env.NODE_ENV or "development"
trust proxy Enables reverse proxy support, disabled by default
jsonp callback name Changes the default callback name of ?callback=
json replacer JSON replacer callback, null by default
json spaces JSON response spaces for formatting, defaults to 2 in development, 0 in production
case sensitive routing Enable case sensitivity, disabled by default, treating "/Foo" and "/foo" as the same
strict routing Enable strict routing, by default "/foo" and "/foo/" are treated the same by the router
view cache Enables view template compilation caching, enabled in production by default
view engine The default engine extension to use when omitted
views The view directory path

Resources