Developer forum

Forum » Templates » Any news on running viewmodel templates with intellisence on mac?

Any news on running viewmodel templates with intellisence on mac?

Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

Heard Nicolai mention it in the presentation of Dynamicweb 9.12

Any news or guideline on how to configure this? Will it work on a hosted solution, or does the solution have to be hosted locally?

/Hans


Replies

 
Nicolai Pedersen
Reply

Hi Hans

Yes, you can actually now get intellisense on MAC using Visual Studio Code. We got it up and running but have not done much testing yet and is still missing a guide on how to set it up.

Dynamicweb 9 still runs in .net framework 4 because of Admin. That means you cannot run it on your mac. But when you setup a templates project, you only need references to Dynamicweb assemblies that are .net standard compliant - they can run on .net core that MAC understands, and this is what can give you intellisense in templates.

Dynamicweb 10 has a new Admin and that will run on mac. We have DW10 running here on a mac (SQL on docker or Windows server though)!

Here is what you can do in Visual Studio code to get a project up and running with Intellisense on MAC

  1. Create a new empty folder and open that in Visual Studio Code
  2. Run these commands in the terminal (VS Code > Terminal > New Terminal)
    1. dotnet new web
    2. dotnet add package Dynamicweb
    3. dotnet add package Dynamicweb.Rendering.Providers.NetCore
    4. dotnet add package Dynamicweb.Ecommerce

That gives you a .net sdk web project with some standard Dynamicweb references - Dynamicweb. Dynamicweb.Rendering (templates) and Dynamicweb.Ecommerce.

The trick here is the Dynamicweb.Rendering.Providers.NetCore which is our .net core version of the template engine. You will not use that in production on DW9, but it gives you intellisense in VSCode.

So now you have a project ready.

Cow copy your dynamicweb "/Files/*" into this folder - that will give you a files node in VS Code explorer with all your templates.

In my example here I have added just 2 templates - page template and a product list template.

To get template intellisense in those template, you need to define the Model of the given template with an 'inherits' statement in the top of the template:

For a Layout template@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>

For a product list template for "Product catalog for viewmodels"

@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Ecommerce.ProductCatalog.ProductListViewModel>

For a product list running the classic product catalog:

@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>

This will give you the intellisense locally - now you just have to publish your templates to the production sites - only the "/Files/*" and not the root of the project.

This guide works on MAC and PC.

Let me hear if you get this up and running.

BR Nicolai

 
Nicolai Pedersen
Reply

Attached find the sample project from above.

I also created a Git repo with some documentation and the possibility to clone the project:

https://github.com/dynamicweb/NetStandardIntellisenseProject

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Ok, thank you veru much Nicolai.

I will try it as soon as possible, and report back 👍🏻

/Hans

 

You must be logged in to post in the forum