/// <summary>Mapper is the Business Logic Layer for the module, this is where the template and data gets mapped to the View Model.</summary> /// <param name="model">The model.</param> /// <param name="moduleContext">The module Context.</param> /// <returns>The <see cref="ModuleViewModel"/>.</returns> internal static ModuleViewModel MapHelloWorldModule(HelloWorldModule model, IMappingContext moduleContext) { var viewModel = new HelloWorldModuleViewModel { HideDescription = model.HideDescription, Greeting = model.Greeting, Text = model.CmsProvider?.Data?.Text, Description = model.CmsProvider?.Data?.Description }; return(viewModel); }
public void BaristaModulesCanReturnJsValues() { var script = @" import helloworld from 'hello_world'; export default helloworld; "; var myHelloWorldModule = new HelloWorldModule(); ModuleLoader.RegisterModule(myHelloWorldModule); using (var rt = BaristaRuntimeFactory.CreateRuntime()) { using (var ctx = rt.CreateContext()) { var result = ctx.EvaluateModule(script); Assert.Equal("Hello, World!", result.ToString()); } } }