I've been looking at different MERN (Mongo-Express-React-Node) builds and really like the look of mern.io. I see how everything fits together in a general sense, although the details of the inner-workings often evades me.
When I attempted to modify the base code by manually creating a new module, it was no bueno. The docs indicate that mern.json can be used to generate new modules, but does not explain how to do so.
How can this file be used to generate new modules?
The current documentation on mern.io and for the mern-starter is lacking this information. You can however find it in the mern-cli package https://github.com/Hashnode/mern-cli
Generate React components, Express routes and controllers and Mongoose models using mern generator.
To list out all available generators
merng
Installation instructions for mern-cli are available in the package README if not already installed. This will allow you to leverage the generators.
Related
I am quite new to Mediawiki and am trying to get templates work.
I managed to get a simple one working but the templates are shown in a weird way but no error is provided.
I looked at your template:
http://wordpress-251650-782015.cloudwaysapps.com/index.php?title=Template:Cita_conferenza
And it invokes a LUA module:
http://wordpress-251650-782015.cloudwaysapps.com/wiki/Modulo:Citazione
You can read more information about using this module on
https://it.wikipedia.org/wiki/Modulo:Citazione
#Revious
A bit late, but you may still be interested...
If you want to copy a template from Wikipedia, but it is using lua modules, you can look in the history tab to find pre-lua versions that use only wikicode (lua has been implemented in 2013 in Wikipedia, but some templates have been given modules later).
Here, it seems to be this version
Be careful, however, if the template you are copying uses subtemplates (this does not seem to be the case here).
If this is the case, you should either make copies of the templates with the same name and code, or add their code to the main template, paying attention to the parameter names which will need to be adapted.
Good luck.
This question is related to ASP.NET 5 (aka vNext) and the new K/KRE.
Background
I want to provide some C# code generation to ASP.NET5 projects by introducing some simple domain specific language (similar to .cshtml or .xaml). Custom MsBuild tasks to create .g.cs files are not used in KRE, so I need the new method of doing DSL code-gen.
Question 1
Are there KRE/Roslyn APIs to hook into the compilation process in the same way that Razor does for .cshtml?
Question 2
During code generation, I would want to access the Roslyn workspace and the AST of the files found from the project.json configuration. Is this possible with the kruntime?
There are some ways of doing this today.
The most practical way to get started is to look at existing parts of ASP.NET 5 that do similar things.
For example:
The Razor repo implements the logic for parsing, processing, and compiling cshtml files.
The CompileModules repo has other kinds of compiler pre/post-processing logic.
These types of scenarios aren't super trivial, so it's difficult to provide exact guidance. I'm not aware of any blog post or article on this topic as it's a fairly new pattern in ASP.NET.
I use Yeoman, and I dig it.
However recently I have been wanting more complex code generation tools - now I know I can build custom generators, but I am wondering if people think this is the role/job/whatever that Yeoman is built to play.
Examples are,
Generating a base REST API (in Node) from a JSON schema
Generating MySQL DB Schema from JSON schema etc.
Although I could bend Yeoman to do this - do people think this is a realistic direction?
Is there a better tool for the job?
(Currently I have a bunch of custom Node scripts that suffice).
My humble opinion:
Yeoman is first and foremost a front end tool to create webapps.
Your task seems to be backend related.
You can still use grunt to scaffold your project though.
http://gruntjs.com/project-scaffolding
Cheers
I'm totally newbie at using AngularJs and although I've been through the tutorials, I still have loads of unanswered questions in my mind. My main concern right now is how should I divide my application into modules ?
Basically I need to build an app which will act as a portal to various apps, each representing a business functionality (sometimes with little to no relationship with each others).
In the tutorial, they show how to create one app with multiple views. What I need, is one app with multiple modules, each module having its own views (and I'll probably have shared views too).
Has anyone worked on an app with that kind of structure ? Could you share your experience and how you've organised things ?
The AngularJS Seed project (https://github.com/angular/angular-seed) is good but it does not really show how to build a complex application.
[EDIT]
I wrote an article on my blog to explain things in more details:
read it on sam-dev.net and you can now read part II, with code sample.
I'll answer my own question. Not because I think it's the best approach, but just because it's the one I've decided to go with.
This is how I've divided my business modules into folders
app
businessModule
controllers
index.js
firstCtrl.js
secondCtrl.js
directives
services
views
filters
anotherBusinessModule
shared
app.js
index.html
Each module has its own folder structure for controllers, directives, etc...
Each folder has an index.js file and then other files to separates each controller, each directive, etc...
The index.js file contains the definition of the module. For instance for the controllers of the businessModule above:
angular.module('myCompany.businessModule.controllers', []);
There's no dependencies here, but there could be any.
Then in firstCtrl.js, I can reuse that module and add the controller to it:
angular.module('myCompany.businessModule.controllers').controller('firstCtrl',
function(){
});
Then the app.js aggregates all the module that I want for my application by adding them to the dependencies array.
angular.module('myApp', ['myCompany.businessModule', 'myCompany.anotherBusinessModule']);
The shared folder contains directives and other things that are not specific to a business module and that can be reused anywhere.
Again, I don't know if it's the best approach, but it definitely works for me. Maybe it can inspire other people.
EDIT
As the index.js files contain modules declarations, they must be referenced in the html page before any other application scripts. To do so, I've used the IBundleOrderer of ASP.NET MVC 4:
var bundle = new ScriptBundle("~/bundles/app") { Orderer = new AsIsBundleOrderer() };
bundles.Add(bundle.IncludeDirectory("~/app", "*.js", true));
public class AsIsBundleOrderer : IBundleOrderer
{
public IEnumerable<FileInfo> OrderFiles(BundleContext context, IEnumerable<FileInfo> files)
{
files = files.OrderBy(x => x.Name == "index.js" ? 0 : 1);
return files;
}
}
Sam's method seems to be the way to go in most cases. The current Angular documentation has it setup as a module for each controller, service, etc, but this has been contradicted by Miško himself from google.
In a recent Angularjs Best Practices video by Miško, he shows how the structure of modules could be laid out for ease of testing as well as easy scaling. Keep in mind how you structure the modules is not supposed to affect performance within an angular app.
From developing angular apps, I would suggest using the best practices method for the aforementioned reasons. You may wish to make your own node script to generate your controllers, etc for the time being which could include say the module you wish to create the controller in and the name, which would then auto generate your controller and proper test spec creation.
If you want a great read on the setup there is an excellent post here regarding setting up the project based on where you think it will be heading.
you should go to the yeoman https://github.com/yeoman/yeoman and yeoman generator structure: https://github.com/yeoman/generator-angular, it becomes a better solution to setup application than angular-seed. For different business modules, you should create different app and share services and directives
For those who are interested, I made a "modularized" version of Angular Seed that fits better with Misko's best practices: https://github.com/sanfordredlich/angular-brunch-seed-modularized
It's set up with Brunch so you very quickly get page reloading, test running and much more. You can be developing quickly and if you follow the patterns in the code, your application should scale reasonably well. Enjoy!
The draw back I have found to the approach the yeoman generator takes is that it doesn't really lineup with the angular modules so it doesn't feel very cohesive to me. So as the project gets larger and you are working on a particular component I found myself flipping around a lot in the source tree.
I have recently come across a different approach here. This approach groups the files by angular modules and feels more cohesive to me. One possible drawback to this is the fact you are required to build the site you can't just run it in place. The grunt watch task in that project helps with this though.
There are so many template engines for node.js and express and there is even this detailed comparison: http://paularmstrong.github.com/node-templates/index.html This led me to check out EJS, Mu2 and JQTpl and I spent some hours on experimenting which of them fits my needs best.
I know that there already are several questions concerning which framework is best, but none of them concentrates on the possibility of using helpers. I tried to build a form helper (which should render input tags and their values if I pass an object into it) together with all of them but I did not find a straight forward way accomplishing it.
Are there any recommendable modules that enable me to use helpers? Maybe even using mustache.js (which - for me - feels like the best of the ones I tried)? Thanks in advance!
I can't point you to the comparison you are looking for, but nearly all the templating engines I've looked at have had a facility for helpers.
If you are using Express (which you mentioned in your question), you can tell Express what helpers you want to expose to whatever template engine you are using (set via the "view engine" app variable) - see the following sections of the Express Guide for details:
View Rendering - explains how to configure Express to use a particular templating engine. The example refers to Jade, which is installed with Express by default, and does support helpers.
Server.helpers() - How to register static view helpers to be passed to your template
Server.dynamicHelpers() How to register helpers which can access the Request and Response objects
Some template engines come with support for Express built in, although they may require an extra configuration step. I am partial to CoffeeKup (and the more updated fork coffeecup), which lets you write your views in Coffeescript; enabling auto-compilation requires and extra call to the Express server object (and covered in the docs):
app.register('.coffee', coffeecup.adapters.express);
Others may offer an additional node package, you may find npm search express- instructive. For example, express-handlebars specifically fixes up app.helpers() and app.dynamicHelpers() to work with handlebars. (Disclaimer: I haven't used this module personally).