MVC patterns with node.js with comon layout and partials - node.js

I am trying to apply mvc pattern (as in ruby) using node.js. I would like also to use a common layout and partials. I saw this post and I tried Locomotivejs, but I don't know how to apply a common layout and partials with Locomotivejs. Should I use another frameworks? if I should, which one has all these features? Could you please give me some suggestion?

You can see what I did in order to solve that problem with locomotive.js here:

Related

Write custom grid layouts with extbase/fluid but without any extension like gridelements

I look for a tutorial, help or an example that tells me what I have to do to write a grid element like 2-colums in basic typo3 (v9) with fluid but no other extension like gridelements, DCE, Templa Voila, etc. I want the same gridelements can do but I dont want to be depended to this extention and move it in my own site extention.
I tried the same with normal content elements (CE) like here:
https://docs.typo3.org/c/typo3/cms-fluid-styled-content/9.5/en-us/AddingYourOwnContentElements/Index.html
But how can I nest a CE in a CE? And how can I do this by drag&drop in the backend?
You can't. The page module doesn't support nesting
You can't nest CEs in a CE. On database level this would mean that you have to make a tt_content record a subrecord of a parent tt_content record. You run into several problems, basically the multilanguage support will be broken and the shortcut element does not function as you will expect it to. That is why the extensions "gridelements" and "mask" exist.
I integrated the gridelements configuration into my sitepackage. So I do not need to bother anymore with it.
Just for your info:
There is now an initiative that works on integrating this functionality into the core (Structured Content Initiative, https://typo3.org/article/a-structured-content-initiative/). Stay tuned to it.
There is nothing special about providing Gridelements via external files, since it's based on TSconfig, TypoScript and Fluid. That's why there is not that much about it in the documentation, since it's the same thing you would do with any other kind of sitepackage. The TSconfig and TypoScript parameters are already explained there, while the Fluid would be up to you anyway.
To have a kind of kickstarter just take any extensions providing Gridelements layouts as an example. A very popular one would be bootstrap_grids, which can be found in the TER or here: https://github.com/laxap/bootstrap_grids
You don't necessarily need the flexform controller of that extension, but the Configuration and Resources folders, show you how to configure stuff and you can see how that is included via ext_localconf.php
There are even comments i.e. in the TSconfig files to explain what is possible there and how to handle i.e. mixed environments with record and file based setups. Although it would be recommended to go for files.
You would at least have to add the necessary backend rendering methods to a draw item hook, that will modify the preview of the container element.
So basically you would have to rewrite everything that DCE, Flux, Gridelements or other similar extensions already do.
Which brings us to the question, why you want to avoid those extensions, since especially those three are well known, widely spread, well supported and available for currently supported TYPO3 versions.

How to use Markdown and Handlebars together?

We are using NodeJS + Express + Handlebars and it works just fine. Now we wont to use Markdown for our documentation. I looked for several days to find something I can use, and the best choice right now is mix of those packages
https://github.com/tj/consolidate.js
https://www.npmjs.com/package/marked-engine
and than register new app engine
app.engine('md', require('marked-engine').renderFile);
The main problem is that I can't use my handlebar layouts with this, so it would be great if there is another approach which would allow me to render Markdown inside handlebar layouts. And I would like to achieve that without Asemblio, Grunt or anything similar if it is possible.
Thank you in advance,
Jovan
This is a tipical use case for a filter in template engines like handlebars. So a fast google search for filters in handlebars lead me to this npm package. And a quick look to the docs show this
{{filter "## Hello *World*!" "markdown"}} → «<h2>Hello <em>World</em>!</h2>»
So maybe this is exactly what you are looking for, in case that this won't work, you should still look for filters, thats the way to go for your problem.
PS: I haven't tested this particular package

Can angular-ui-grid be used with angular material design?

The title pretty much says it all: Can angular ui-grid be used with angular material design in a way that follows the material design principles?
It can, but only at a look and feel level. Basically most of the visual elements in ui-grid are over-rideable with templates (cellTemplate, rowTemplate etc). You can also override a lot of the css. So if you're prepared to work through it there's no reason why most of it cannot be tailored.
Be aware that the customize style option on the ui-grid site does not give you the ability to change most of the classes that you will eventually need to in order to make it conform to the material design spec. Additionally it lacks responsive features or the ability to create the kinds of animations/transitions that are a signature of material design.
I really like both projects, its just hard to try and build an app on two frameworks that are currently under active development. I am using ui-grid in my Angular-Material app, but I don't think I would if I had to do it over again

Can I display multiselect list items as onordered list using Razor?

I was wondering if this is possible with razor syntax (I have found that there are other ways that utilize jquery). Please point me in the right direction if you know one. I am working on a MVC 5 project.
Thanks.
Yes, this is possible by creating custom html helper methods. Refer this little example which would be helpful.
Video version of tutorial

For loops and layout support in express.js template engine

I come from a PHP background and I've used frameworks such as CakePHP and Laravel and it is quite easy to work with layouts and views in all of them.
And the possibility of using PHP inside those template engines provide a way to do things such as:
<?php for($i=0; $i<1000; $i++){ ?>
<td>demo</td>
<? } ?>
Now, starting with Node and express.js I found out template engines seems quite basic here. I've tried hjs, hogan, swig, mustache, handlebars... none of them offers both :
Layout support (templates and views)
A way to do loops like the one I named before.
Am I missing something? Am I asking for too much?
Which one would you recommend me?
A lot of the template engines for Javascript take the philosophical view that it's better to enforce a fairly strict separation between logic and presentation, meaning that the complexity of code/logic allowed in the template is deliberately limited. For a quick overview of this topic, see http://blog.startifact.com/posts/older/the-new-hot-thing-in-web-development-client-side-templating-languages.html (it's about client-side templating, but since it's Javascript, a lot of those same template languages are the ones popular in node.js / Express). This idea of logicless templates exists in the PHP world as well, it's just not as common.
For a more academic treatment of this subject, see this paper: http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf. (The author is also the author of a popular template engine for Java called StringTemplate.) The author makes a lot of good points, and in general I agree with the idea of logicless templates, but there are times when it can be inconvenient and I find myself more on the fence about it...see this link for some further considerations. Obviously there are also those who want to be able to anything from a template (as you can in PHP) and believe it's fine to rely on the self-restraint of the programmer not to put too much code in the view, which is where template engines like EJS come in.
Having said all that, it's important to note that what you want to achieve is possible in Handlebars (which is one of the "logicless" languages) and probably many of the others you tried as well. To do it in Handlebars, you'd need to create a custom helper. This might be what you're looking for:
https://www.npmjs.org/package/handlebars-helper-repeat
Example usage:
{{#repeat 10}}
{{> button }}
{{/repeat}}
You could also extend it to be able to support arguments to be able to control the starting number or increment, although that would probably be getting into logic that might be better done in the JS code (according to the Handlebars philosophy) while preparing the data for the template.
With regard to layouts, the closest thing in Handlebars (which is the template engine I'm most familiar with) is partials. This link provides a good introduction to those: http://blog.teamtreehouse.com/handlebars-js-part-2-partials-and-helpers.
Personally I'm a big fan of the template language in an awesome framework (built on Express) called Derby. Its template language is similar to Handlebars, but comes with a couple of handy extensions - just enough to make it a bit more convenient to use without allowing too much logic to creep into the template. Unfortunately I don't think there's a standalone version of it (i.e. you have to use the full Derby framework), but you could create custom helpers in Handlebars to achieve a similar effect.

Resources