The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

505970 (10) [Avatar] Offline
#1
While going through chapter 4 Templates I see that originalNumberOfBooks is camel case in the view-model but in the view it is cabob case with the (dot) .one time. why is it cabob case and not just all lowercase or camel case?

Thank you,
Sean Hunter (29) [Avatar] Offline
#2
Thanks for the feedback. This should be consistent. I'll review the listings around that and correct for the upcoming MEAP smilie.

Cheers,
SEan
505970 (10) [Avatar] Offline
#3
I think the listings are correct. Typescript throws a compile error if it is any other way then cabob case, I was just wondering way that is? Is that the convention for multiple word attributes?
Sean Hunter (29) [Avatar] Offline
#4
Ah yes, my apologies. I didn't read this correctly.

Aurelia uses InitCase within view-models and kebab-case in view templates. The naming convention is described here:

https://livebook.manning.com#!/book/aurelia-in-action/chapter-3/v-5/point-663-56-56-0

Cheers,
Sean
505970 (10) [Avatar] Offline
#5
I think there may be some confusion. I'm not referring to the file naming convention. in book-stats we have a property named originalNumberOfBooks like bellow
import {computedFrom, bindable} from 'aurelia-framework';
 
export class BookStats{
 
  @bindable books;
  @bindable originalNumberOfBooks;
 
  @computedFrom('originalNumberOfBooks', 'books.length')
  get addedBooks(){
      return this.books.length—this.originalNumberOfBooks;
  }
}


then in books.html we bind to it as bellow
<template>
..
<require from="./book-stats"></require>
...
<book-stats if.bind="books.length > 0"
     books.bind="books"
original-number-of-books.one-time="books.length">
</book-stats>
</template>


Then my question is why is the binding original-number-of-books.one-time instead of originalNumberOfBooks.one-time or originalnumberofbooks.one-time? is the kebob case in the html a convention and so should be followed for multi-worded properties?

when trying both originalNumberOfBooks.one-time or originalnumberofbooks.one-time I get a build error specifying to try the original-number-of-books instead.
Sean Hunter (29) [Avatar] Offline
#6
Ah ok yes that makes sense, apologies for the delayed reply.

Generally, the convention indicates that everything should be kebab-case in the view with the exception of when you have a JavaScript expression in you binding (for example: click.delegate="removeBook($index)").

Cheers,
Sean