내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Concatenating two string in HTL java-script use api

Avatar

Level 2

We are facing issue trying to concatenating two string in in HTL java-script use api .

In my info.js (rendering server side and used in template using data-sly-use 😞

var a = ‘String 1’,       
b -= ‘String 2’

Option 1: var c = a+’_’+ b; //Tried concatenating with ‘+’

Expected String 1_ String 2

Getting: Java error

Option 2: var c = a.concat(_).concat(b) // Tried concat operation

Expected String1_String2

Getting: Sting1,_,String2

Option 3: var c=[];

  1. c.push=a;
  2. c.push=b;
  3. c.join(‘_’) // Tried join

Expected: String1_String2

Getting: [Ljava.lang.String;@83e0d6bf_[Ljava.lang.String;@e4896fbb_JPEG

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Employee

I Just tried this and it worked for me.

info.js

use(function () {

   

    var value1 = "Experince";

    var value2 = "Manager";

    var retValue = value1 + " " + value2;

    return {

        newValue: retValue

    };

});

and in my component,

<p data-sly-use.info="info.js">${info.newValue}</p>

Output:

Experience Manager

If you still see the issue, Can you paste the code snippet?

원본 게시물의 솔루션 보기

1 답변 개

Avatar

정확한 답변 작성자:
Employee

I Just tried this and it worked for me.

info.js

use(function () {

   

    var value1 = "Experince";

    var value2 = "Manager";

    var retValue = value1 + " " + value2;

    return {

        newValue: retValue

    };

});

and in my component,

<p data-sly-use.info="info.js">${info.newValue}</p>

Output:

Experience Manager

If you still see the issue, Can you paste the code snippet?