\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Erik Hanchett (ErikCH)} \pdfinfo{ /Title (aurelia-getting-started.pdf) /Creator (Cheatography) /Author (Erik Hanchett (ErikCH)) /Subject (Aurelia Getting Started Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{231FA3} \definecolor{LightBackground}{HTML}{F1F1F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Aurelia Getting Started Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Erik Hanchett (ErikCH)} via \textcolor{DarkBackground}{\uline{cheatography.com/20589/cs/3750/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Erik Hanchett (ErikCH) \\ \uline{cheatography.com/erikch} \\ \uline{\seqsplit{www}.ProgramWithErik.com} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 29th March, 2015.\\ Updated 11th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Quick Getting Started}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{1. npm install -g gulp} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{2. npm install -g jspm} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{3. jspm registry config github} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{4. Download skeleton-navigation \seqsplit{https://github.com/aurelia/skeleton-navigation/releases}} \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{5. Change directories to skeleton directory} \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{6. npm install} \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{7. jspm install -y} \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{8. gulp watch} \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Make sure to have node installed first} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Templating Examples}} \tn % Row 0 \SetRowColor{LightBackground} .one-way & `\textless{}markdown-editor value.one-way="markdown"\textgreater{}\textless{}/markdown-editor\textgreater{}` \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} .two-way & `\textless{}markdown-editor value.two-way="markdown"\textgreater{}\textless{}/markdown-editor\textgreater{}` \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} .bind & `\textless{}input type="text" value.bind="firstName"\textgreater{} \textless{}a href.bind="url"\textgreater{}Aurelia\textless{}/a\textgreater{}` \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} trigger & `\textless{}button click.trigger="sayHello()"\textgreater{}Say Hello\textless{}/button\textgreater{}` \tn % Row Count 12 (+ 3) % Row 4 \SetRowColor{LightBackground} delegate & `\textless{}button click.delegate="sayHello()"\textgreater{}Say Hello\textless{}/button\textgreater{}` \tn % Row Count 15 (+ 3) % Row 5 \SetRowColor{white} call & `\textless{}div touch.call="sayHello()"\textgreater{}Say Hello\textless{}/button\textgreater{}` \tn % Row Count 17 (+ 2) % Row 6 \SetRowColor{LightBackground} string \seqsplit{interpolation} & `\textless{}div class="dot \$\{color\} \$\{isHappy ? 'green' : 'red'\}"\textgreater{}\textless{}/div\textgreater{}` \tn % Row Count 20 (+ 3) % Row 7 \SetRowColor{white} ref & `\textless{}input type="text" ref="name"\textgreater{} \$\{name.value\}` \tn % Row Count 22 (+ 2) % Row 8 \SetRowColor{LightBackground} select & `\textless{}option repeat.for="color of colors" value.bind="color"\textgreater{}\$\{color\}\textless{}/option\textgreater{}` \tn % Row Count 25 (+ 3) % Row 9 \SetRowColor{white} inner html & `\textless{}div innerhtml.bind="htmlProperty"\textgreater{}\textless{}/div\textgreater{} \textless{}div innerhtml="\$\{htmlProperty\}"\textgreater{}\textless{}/div\textgreater{}` \tn % Row Count 29 (+ 4) % Row 10 \SetRowColor{LightBackground} textContent & `\textless{}div textcontent.bind="stringProperty"\textgreater{}\textless{}/div\textgreater{} \textless{}div textcontent="\$\{stringProperty\}"\textgreater{}\textless{}/div\textgreater{}` \tn % Row Count 33 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Templating Examples (cont)}} \tn % Row 11 \SetRowColor{LightBackground} style & `\textless{}div style.bind="styleString"\textgreater{}\textless{}/div\textgreater{} \textless{}div style.bind="styleObject"\textgreater{}\textless{}/div\textgreater{}` \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Template Example Code}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\textless{}template\textgreater{} \newline \textless{}section\textgreater{} \newline \textless{}h2\textgreater{}\$\{heading\}\textless{}/h2\textgreater{} \newline \newline \textless{}form role="form" submit.delegate="welcome()"\textgreater{} \newline \textless{}div class="form-group"\textgreater{} \newline \textless{}label for="fn"\textgreater{}First Name\textless{}/label\textgreater{} \newline \textless{}input type="text" value.bind="firstName" class="form-control" id="fn" placeholder="first name"\textgreater{} \newline \textless{}/div\textgreater{} \newline \textless{}div class="form-group"\textgreater{} \newline \textless{}label for="ln"\textgreater{}Last Name\textless{}/label\textgreater{} \newline \textless{}input type="text" value.bind="lastName" class="form-control" id="ln" placeholder="last name"\textgreater{} \newline \textless{}/div\textgreater{} \newline \textless{}div class="form-group"\textgreater{} \newline \textless{}label\textgreater{}Full Name\textless{}/label\textgreater{} \newline \textless{}p class="help-block"\textgreater{}\$\{fullName | upper\}\textless{}/p\textgreater{} \newline \textless{}/div\textgreater{} \newline \textless{}button type="submit" class="btn btn-default"\textgreater{}Submit\textless{}/button\textgreater{} \newline \textless{}/form\textgreater{} \newline \textless{}/section\textgreater{} \newline \textless{}/template\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{All templates must start with \textless{}template\textgreater{} and end with \textless{}/template\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.63781 cm} x{2.33919 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{HTTP Client Methods}} \tn % Row 0 \SetRowColor{LightBackground} Install & jspm install \seqsplit{aurelia-http-client} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} createRequest(uri) & Custom configure individual requests \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} delete(uri) & HTTP Delete request \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} get(uri) & HTTP Get Request \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} head(uri) & HTTP Head Request \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} jsonp(uri, \seqsplit{callbackParameterName='jsoncallback')} & Sends \seqsplit{JSONPReqeustMessage} \tn % Row Count 11 (+ 3) % Row 6 \SetRowColor{LightBackground} put(uri, content) & HTTP Put Request \tn % Row Count 12 (+ 1) % Row 7 \SetRowColor{white} patch(uri, content) & HTTP Patch Request \tn % Row Count 13 (+ 1) % Row 8 \SetRowColor{LightBackground} post(uri, content) & HTTP Post Request \tn % Row Count 14 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{The result of sending a message is a promise, it has the following properties. response, responseType, content, headers, statusCode, statusText, isSuccess, reviver, requestMesssage} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{HTTP Client Example (Flickr)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{import \{HttpClient\} from 'aurelia-http-client'; \newline \newline var url = \seqsplit{'http://api.flickr.com/services/feeds/photos\_public.gne?tags=rainier\&tagmode=any\&format=json';} \newline \newline export class Flickr\{ \newline static inject() \{ return {[}HttpClient{]}; \} \newline constructor(http)\{ \newline this.heading = 'Flickr'; \newline this.images = {[}{]}; \newline this.http = http; \newline \} \newline \newline activate()\{ \newline return \seqsplit{this.http.jsonp(url).then(response} =\textgreater{} \{ \newline this.images = response.content.items; \newline \}); \newline \} \newline \newline canDeactivate()\{ \newline return confirm('Are you sure you want to leave?'); \newline \} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{jsonp requet returns a promise} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Extending HTML Behaviours}} \tn % Row 0 \SetRowColor{LightBackground} Attached Beahviours & Adds new behavior or functionality to existing HTML element \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Custom Elements & New tags to HTML Markup \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} Template Controllers & Convert Dom into inert HTML template \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Behavior Examples}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{//Attached Behavior (jquery) \newline \textless{}div show.bind="isSaving" class="spinner"\textgreater{}\textless{}/div\textgreater{} \newline import \{Behavior\} from 'aurelia-templating'; \newline \newline export class Show \{ \newline static metadata()\{ \newline return Behavior \newline \seqsplit{.attachedBehavior('show')} \newline .withProperty('value', 'valueChanged', 'show'); \newline \} \newline \newline //Custom Element \newline \textless{}template\textgreater{} \newline \textless{}require from="./say-hello"\textgreater{}\textless{}/require\textgreater{} \newline \newline \textless{}input type="text" ref="name"\textgreater{} \newline \textless{}say-hello to.bind="name.value"\textgreater{}\textless{}/say-hello\textgreater{} \newline \textless{}/template\textgreater{} \newline import \{Behavior\} from 'aurelia-templating'; \newline \newline export class SayHello \{ \newline static metadata()\{ \newline return Behavior \newline \seqsplit{.customElement('say-hello')} \newline .withProperty('to'); \newline \} \newline \newline speak()\{ \newline alert('Hello \$\{this.to\}!'); \newline \} \newline \} \newline \newline //Template Controllers \newline \newline li repeat.for="customer of customers"\textgreater{}\$\{customer.fullName\}\textless{}/li\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Routing Activation Lifecycle}} \tn % Row 0 \SetRowColor{LightBackground} canActivate(params, queryString, routeConfig) & Hook to be navigated too \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} activate(params, queryString, routeConfig) & Custom logic before view-model is displayed \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} canDeactivate() & Router can navigate from view? \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} deactivate() & Logic as you are being navigated from \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Router Example}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{import \{Router\} from 'aurelia-router'; \newline import bootstrap from 'bootstrap'; \newline \newline export class App \{ \newline static inject() \{ return {[}Router{]}; \} \newline constructor(router) \{ \newline this.router = router; \newline \seqsplit{this.router.configure(config} =\textgreater{} \{ \newline config.title = 'Aurelia'; \newline config.map({[} \newline \{ route: {[}'','welcome'{]}, moduleId: './welcome', nav: true, title:'Welcome' \}, \newline \{ route: 'flickr', moduleId: './flickr', nav: true \}, \newline \{ route: 'child-router', moduleId: './child-router', nav: true, title:'Child Router' \} \newline {]}); \newline \}); \newline \} \newline \} \newline \textasciitilde{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{DI Example}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{import \{HttpClient\} from 'aurelia-http-client'; \newline \newline export class CustomerDetail\{ \newline static inject() \{ return {[}HttpClient{]}; \} \newline constructor(http)\{ \newline this.http = http; \newline \} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}