Comments (12)
You can change the default template type which is FluidTemplate
.
FluidTemplate.Factory.RegisterTag<QuoteTag>("quote");
from fluid.
I am adding it to the documentation
from fluid.
using Fluid.MvcViewEngine;
and not using FluidViewTemplate
from fluid.
@sebastienros Thank you for the suggestion!
Would the above go in Startup.cs
, or somewhere else?
I tried this:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
TemplateContext.GlobalMemberAccessStrategy.Register<Person>();
TemplateContext.GlobalFilters.AddFilter("slug", SlugifyFilter.Slugify);
FluidTemplate.Factory.RegisterTag<SvgTag>("svg");
}
}
But I still see a syntax error in the view:
Exception: Syntax error, expected: if, endif, elsif, else, unless, endunless, case, endcase, when, for, endfor, continue, break, comment, endcomment, raw, endraw, cycle, assign, capture, endcapture, increment, decrement, include, layout, renderbody, section, endsection, rendersection at line:0, col:3
from fluid.
Try in the static constructor of the Startup class, to be sure it's run before anything.
from fluid.
If that still doesn't work I assume I will need to change the way we register the view engine to provide a custom template type, which will be one of yours like in the documentation.
from fluid.
Just tried this:
public class Startup
{
static Startup()
{
FluidTemplate.Factory.RegisterTag<SvgTag>("svg");
}
public Startup(IConfiguration configuration)
{
Configuration = configuration;
TemplateContext.GlobalMemberAccessStrategy.Register<Person>();
TemplateContext.GlobalFilters.AddFilter("slug", SlugifyFilter.Slugify);
// FluidTemplate.Factory.RegisterTag<SvgTag>("svg");
}
}
Same result (no compilation errors, but same error in the view).
from fluid.
Got it working, you actually need to change FluidViewTemplate
:
static Startup()
{
FluidViewTemplate.Factory.RegisterTag<MyTag>("mytag");
}
from fluid.
@sebastienros I feel like I still might be missing something. When I change FluidTemplate
to FluidViewTemplate
, I see compilation errors like this:
Startup.cs(7,7): error CS0246: The type or namespace name 'FluidViewTemplate' could not be found (are you missing a using directive or an assembly reference?)
Here is a larger look at my Startup.cs
file, so you can see what directives I'm using as well:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ClientName.Models;
using Fluid;
using FluidViewTemplate;
using FluidMvcViewEngine;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using ClientName.Liquid.Filters;
using ClientName.Liquid.Tags;
namespace ClientName
{
public class Startup
{
static Startup()
{
FluidViewTemplate.Factory.RegisterTag<SvgTag>("svg");
}
public Startup(IConfiguration configuration)
{
Configuration = configuration;
TemplateContext.GlobalMemberAccessStrategy.Register<Person>();
TemplateContext.GlobalFilters.AddFilter("slug", SlugifyFilter.Slugify);
// FluidTemplate.Factory.RegisterTag<SvgTag>("svg");
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddMvc().AddFluid().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
from fluid.
Maybe you are missing a using statement. Look at the sample that does that in the repo.
from fluid.
Apparently you typed using
statement by hand, hoping you'd be lucky ... you were not. Try to use Intellisense for that ;)
from fluid.
Apparently you typed
using
statement by hand, hoping you'd be lucky ... you were not. Try to use Intellisense for that ;)
Ha, in this case I wasn't the one who created the Startup.cs
! But you're right, using Fluid.MvcViewEngine
appears to have been missed, and restoring it fixes the problem.
Thanks for your help!
from fluid.
Related Issues (20)
- Question: Is it possible to use Layout and Sections tags with streams rather than paths HOT 2
- Question: Multiple arguments/parameters for tag HOT 3
- Access root object from template HOT 3
- Include statement circular dependency HOT 8
- Current local date and time not converting to specified timezone HOT 2
- Question: Introspection of parsed template HOT 6
- Question: is this library suited for implement something like Microsoft Guidance?
- {% render "filename" %} with custom extensions HOT 2
- Access properties of dictionary value HOT 1
- Fluid.Tags compatibility method after upgrading to a new version HOT 1
- Question: Update underlying Liquid version HOT 2
- Layout support doesn't seem to work in 2.4.0 HOT 10
- Hope size supports null HOT 1
- Missing fluid compatibilty table and roadmap HOT 1
- Synchronous operations are disallowed
- Fluid prints nothing inside for ..in loop HOT 2
- Make TemplateContext.LocalScope public
- Template not rendering
- Recusive variable resolving
- Include/Render Statement Cache Not Refreshed When File Content Changed HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluid.