Build a Drupal-Free With 8's REST API and Javascript: DrupalCon Austin Session Notes

Wayne Eaker
Theme Developers
Build a Drupal-Free With 8's REST API and Javascript: DrupalCon Austin Session Notes

Drupal Theming

  • Divitis
  • A lot of Drupalisms all throughout the HTML
  • Lots of templates to override to do simple things

A Different Approach

  • AngularJS
  • Need raw data for Angular. No theming, no divs, etc.
  • Web Services and REST in Drupal 8 core
  • Accept header: application/hal+json
  • CORS module: allow pulling data from a different URL from the site you're on.
  • Client Side Theme: Not a Drupal theme. Totally decoupled.

Angular

  • index.html, app.js, angular.js
  • ng-controller: Builds a $scope variable like $variables array in normal theme.
  • Use $http service to do REST request
  • Create an Angular "service" for retrieving data of a particular type
  • Routing: angular-route.js
  • Wildcards with $routeparams
  • Can specify template files for your various routes.
  • DBLogResource module: example of wrapping custom data in REST in D8