Skip to content

translate directive along with other transclude directive #132

Description

@adrianandreias

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>

Activity

  1. gabegorelick commented on Nov 24, 2014

    @gabegorelick
    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.

  2. adrianandreias commented on Nov 25, 2014

    @adrianandreias
    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.

  3. rubenv commented on Nov 25, 2014

    @rubenv
    Owner

    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.

  4. gabegorelick commented on Nov 25, 2014

    @gabegorelick
    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 notifications@github.com
    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)
    .

  5. rubenv commented on Nov 25, 2014

    @rubenv
    Owner

    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.

  6. gabegorelick commented on Nov 25, 2014

    @gabegorelick
    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 notifications@github.com
    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)
    .

  7. rubenv commented on Nov 25, 2014

    @rubenv
    Owner

    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.

  8. gabegorelick commented on Nov 25, 2014

    @gabegorelick
    Collaborator

    Yeah the compatibly goes without saying :)

    On Tuesday, November 25, 2014, Ruben Vermeersch notifications@github.com
    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)
    .

  9. gabegorelick commented on Dec 8, 2014

    @gabegorelick
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions