6

Does anyone have an experience in using Craft in conjunction with a front-end JS MVC/MVVM framework such as Backbone, Ember or Angular?

We have a project coming up where there may be a lot of JS state management requirement and AJAX calls required, and would like to access back-end data using JSON. However, there is also a strong need for a robust easy-to-use CMS as there will be a lot of content to administer.

My first port of call for this type of application would be some more general server-side framework such as Laravel, but Craft has sort of spoiled us with the content management side of things.

Is there any way of marrying Craft with this kind of project?

2 Answers 2

5

I am just starting out on a project using both Craft and Angular. I ran into an early issue because both Angular and Twig use the {{ }} braces, but that was quickly fixed by changing Angular’s settings like in this Stackover flow post.

As Christian noted in the comments, though, you could also use the {% verbatim %} tag to keep Craft from parsing Angular tags.

Aside from that, I haven't had issues since Craft gives you full frontend control and there are no CMS scripts on the frontend to worry about. And (so far) Craft's dynamic routes make it really quite easy to set up your templates, JSON, etc.

3
  • 1
    Twig also has the {% verbatim %} tag for sections that shouldn't be parsed. I'd simply wrap my Angular code with that.
    – carlcs
    Commented Jul 4, 2014 at 14:50
  • This is a great point - I've heard that some outside Angular modules may have braces hardcoded, so this may be a more surefire way for them to work properly. Commented Jul 4, 2014 at 14:54
  • Braces can be escaped too. Commented Jul 27, 2017 at 21:35
1

I believe there are ways to marry them and I've been exploring just that with Vue. I'm not an expert in plugin development but I believe it involves POSTing the AJAX to a custom controller that you write, which can then save entries to the database via the service layer. This post I found useful as a place to start and has some good introductory information. This developer writes about his experience using Vue and Craft here and here.

Beyond that, I haven't seen a lot! But I'm curious to know the same thing. Indeed I would happily pay for a course if somebody were to make one. (Mijingo, I'm looking at you (Also at Udemy).)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.