Assets and namespaces (tests are pased) #2

wants to merge 28 commits into

2 participants


No description provided.


Really sweet :)

@kuraga kuraga fix 3
Apotomo uses Ruby 1.8 syntax!

Don't you think that Namespace.js shouldn't be in Apotomo? I can crate a gem for it...


I'm not sure if Namespace.js is the best option? I just needed something that would provide namespaces for pure javascript in an easy fashion. Perhaps we should just stick with coffeescript for now, and not support non-coffeescript (since coffee is default in Rails anyways!).


About call_fun, I think you should provide a block wrapper construct like I suggested previously.

call_fun :toggle_active, 'TopBar', {item: 'item:first'}`

# enter widget TopBar scope
js_widget :top_bar do |w|
  w.call_fun :toggle_active,  {item: 'item:first'}
  w.call_fun :toggle_active,  {item: 'item:last'}

# for deeper namespace, use String
js_widget 'My::TopBar' do |w|
  w.call_fun :toggle_active,  {item: 'item:first'}
  w.call_fun :toggle_active,  {item: 'item:last'}

# or "." syntax
js_widget 'My.TopBar' do |w|

Nice ;)


About Namespace.js: I don't know about library choice because I didn't work with JavaScript namespaces... But library is not maintained, yes?

But the main thought that library should be in a separated gem... And what's the reason to make _library_in CoffeeScript? No, I think libraries (if they are still not in a separated gem) should be in a 'precompiled form', or in original form.


About technologies: I think we should with Nick about them. And I have a thought about fixing technologies stack... I.e. Ruby 1.9.3 and Rails 3.2+ only... I don't know. But we may clean code base, couple/decouple some features... And break compatibility making a new major version... If Nick will want. And 'not support non-coffeescript' for example. I think we may to think complexity: it's time to upgrade Apotomo! ;-)

But I think we should fix technologies used for docs examples. I.e. make all examples in haml and coffeescript (erb and javascript).


About wrapper: I agree but I don't have time for this now. I can do something later but I want to make existance patches stable. Because I'll understand what and how should I do for a new functionality.


Instead of Namespace.js I thingit is better to just use Require.js which does the same thing but is much more advanced ;)


kuraga added some commits Mar 19, 2013
@kuraga kuraga fix 4
We didn't refactor tree structure yet!
@kuraga kuraga fix 5
We didn't rename `display` to show yet!
@kuraga kuraga fix 6 ad4f407
@kuraga kuraga fix 7
Restore JqueryHelper
@kuraga kuraga small typo 75ea0a2

Oh, I didn't understand that there is two variants here: and isn't a coffeescript version of Namespace.js!. And Namespace.js is similar to Require.js (they do load modules async) but is a nano-lib to (just) make modules. By the other side does we require a load functionality such as Require.js?

Okay, we need only four magic locs to create namespace name with values...

# *Export the specified value(s) to the specified package name.*
window.namespace = ( name, values ) ->
  # Export to `exports` for node.js or `window` for the browser.
  target = window
  # Nested packages may be specified using dot-notation, and are automatically created as needed.
  target = target[ subpackage ] ||= {} for subpackage in name.split( '.' )
  # Export each value in the specified values Object to the specified package name by the value's key.
  target[ key ] = value for key, value of values

Like I said, I think it is much better to use RequireJS for modules in case it is pure javascript. But please focus on the Coffeescript functionality, and leave it to others as an exercise if they want to use pure js.

But maybe your simple Namespace JS "hack" is enough for our needs?

Focus on the ideas I sent you for the stateful widgets and dynamic widget tree ;) Much more important IMO.



My hack is a copy of (not Namespace.js which is much bigger, 500+ locs). But it can be rewritten in JavaScript. There are fifteen locs but not five :) Yes, they're enough - these five lines.


Tests are passed but I don't know if every thing is tested.


And I don't like names of options: --js and --style. I want to make it Rails-style.

P.S. And I don't understand why Apotomo isn't connected with haml-rails etc and make these options defaults right...


Yeah, make haml-rails or even slim the default ;) PS: I also like the new "curly templates" ;)


The next thing that I'll do: #2 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment