Skip to content

translate directive along with other transclude directive #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
adrianandreias opened this issue Nov 24, 2014 · 9 comments
Closed

translate directive along with other transclude directive #132

adrianandreias opened this issue Nov 24, 2014 · 9 comments

Comments

@adrianandreias
Copy link

I'm using the translate directive on a tag that also has another transclude directive:

<div translate demo>Some text</div>
  demo = (function() {
    function demo() {
      return {
        transclude: true,
        template: "<p>Bla, bla <span ng-transclude></span></p>"
      };
    }

    return demo;

  })();

(JavaScript was automatically generated from CoffeeScript with ng-classify:

class demo extends Directive
    constructor: ->
        return {
            transclude: true
            template: """
                      <p>Bla, bla <span ng-transclude></span></p>
                      """
        }

)

Setting demo directive's priority to -1000 translates Some text but replaced the demo's template entirely.

Is this supposed to work somehow? or I must to put translate on another inner tag:

<div demo><span translate >Some text</span></div>
@gabegorelick
Copy link
Collaborator

Is this supposed to work somehow? or I must to put translate on another inner tag:

I believe so, since the translate directive has default priority of 0 and is terminal. You can read up on directive priorities and terminal here.

Like you mentioned, wrapping the string in a span is usually what you want to do.

@adrianandreias
Copy link
Author

I'm still trying to avoid the inner <span> if this is possible.
Is there a reason the translate directive has to have terminal: true?

I my case I need translate directive to run first and then my demo directive. But that's not possible if translate has terminal: true.

@rubenv
Copy link
Owner

rubenv commented Nov 25, 2014

This isn't caused because of terminal: true. Having it in place makes directives at different priorities possible.

I my case I need translate directive to run first and then my demo directive. But that's not possible if translate has terminal: true.

Check the docs link mentioned by @gabegorelick, you might want to look into directive priorities.

@gabegorelick
Copy link
Collaborator

Actually, I believe it is caused by terminal. Terminal says to not execute
directives at lower priority, which appears to be the issue the poster is
complaining about.

That being said, I still think limiting other directives on the translate
element is the way to go because otherwise the ordering can get confusing.
It's best to wrap it in a span.

On Tuesday, November 25, 2014, Ruben Vermeersch [email protected]
wrote:

This isn't caused because of terminal: true. Having it in place makes
directives at different priorities possible.

I my case I need translate directive to run first and then my demo
directive. But that's not possible if translate has terminal: true.

Check the docs link mentioned by @gabegorelick
https://github.com/gabegorelick, you might want to look into directive
priorities.


Reply to this email directly or view it on GitHub
#132 (comment)
.

@rubenv
Copy link
Owner

rubenv commented Nov 25, 2014

Actually, I believe it is caused by terminal. Terminal says to not execute
directives at lower priority, which appears to be the issue the poster is
complaining about.

I checked things again and yes, you are right. We used to have the double-directive trick that's also used by ngView. Nowadays it seems we only use one directive. We can probably get rid of terminal, but it won't fix the issue at hand.

@gabegorelick
Copy link
Collaborator

We could set the translate directive at a different priority. But should it
be higher priority or lower? Again, probably best to keep it as is and just
make people wrap it in a span for clarity.

On Tuesday, November 25, 2014, Ruben Vermeersch [email protected]
wrote:

Actually, I believe it is caused by terminal. Terminal says to not execute
directives at lower priority, which appears to be the issue the poster is
complaining about.

I checked things again and yes, you are right. We used to have the
double-directive trick that's also used by ngView. Nowadays it seems we
only use one directive. We can probably get rid of terminal, but it won't
fix the issue at hand.


Reply to this email directly or view it on GitHub
#132 (comment)
.

@rubenv
Copy link
Owner

rubenv commented Nov 25, 2014

We could set the translate directive at a different priority.

Not without breaking compatibility: people might be depending on the existing behavior.

I too recommend just throwing a span in there. Happens in a gazillion other places as well in Angular.JS.

@gabegorelick
Copy link
Collaborator

Yeah the compatibly goes without saying :)

On Tuesday, November 25, 2014, Ruben Vermeersch [email protected]
wrote:

We could set the translate directive at a different priority.

Not without breaking compatibility: people might be depending on the
existing behavior.

I too recommend just throwing a span in there. Happens in a gazillion
other places as well in Angular.JS.


Reply to this email directly or view it on GitHub
#132 (comment)
.

gabegorelick added a commit to gabegorelick/angular-gettext that referenced this issue Dec 8, 2014
@gabegorelick
Copy link
Collaborator

#147 makes the directive non-terminal. That should fix some of the issues brought up in this bug report. But in general <span> is your friend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants